2
0

ThreadPool.hx 826 B

12345678910111213141516171819202122232425262728293031
  1. package eval.luv;
  2. @:forward
  3. abstract ThreadPoolRequest(Request) to Request {}
  4. /**
  5. Thread pool.
  6. @see https://aantron.github.io/luv/luv/Luv/Thread_pool
  7. **/
  8. extern class ThreadPool {
  9. static function createRequest():ThreadPoolRequest;
  10. /**
  11. Schedules a function to be called by a thread in the thread pool.
  12. `work` is the function that will be called in the thread pool.
  13. `callback` will be called by the `loop` after `work` completes, or
  14. immediately, in case there is an error scheduling `work`.
  15. **/
  16. static function queueWork(loop:Loop, ?request:ThreadPoolRequest, work:()->Void, callback:(result:Result<Result.NoData>)->Void):Void;
  17. /**
  18. Sets thread pool size.
  19. This function should be called as soon during process startup as possible.
  20. **/
  21. static function setSize(size:Int, ?ifNotAlreadySet:Bool):Void;
  22. }