Turi Create
4.0
|
#include <core/system/lambda/worker_pool.hpp>
Public Member Functions | |
std::unique_ptr< worker_process< ProxyType > > | get_worker () |
std::shared_ptr< worker_guard< ProxyType > > | get_worker_guard (std::unique_ptr< worker_process< ProxyType >> &worker) |
void | release_worker (std::unique_ptr< worker_process< ProxyType >> &worker) |
size_t | num_workers () const |
size_t | num_available_workers () |
template<typename RetType , typename Fn > | |
std::vector< RetType > | call_all_workers (Fn f) |
worker_pool (size_t num_workers, std::vector< std::string > worker_binary_and_args, int connection_timeout=3) | |
constructor | |
~worker_pool () | |
destructor | |
Manage a list of worker_processes.
get_worker()/release_worker() are thread safe.
Definition at line 287 of file worker_pool.hpp.
|
inline |
Call the function on all worker in parallel and return the results. Block until all workers are available.
Definition at line 364 of file worker_pool.hpp.
|
inline |
Return the next available worker. Block until any worker is available. Throws error if worker_pool has zero workers.
Definition at line 299 of file worker_pool.hpp.
|
inline |
Returns a worker_guard for the given worker. When the worker_guard goes out of the scope, the guarded worker will be automatically released.
Definition at line 312 of file worker_pool.hpp.
|
inline |
Return number of avaiable workers in the pool.
Definition at line 354 of file worker_pool.hpp.
|
inline |
Return number of total workers in the pool.
Definition at line 349 of file worker_pool.hpp.
|
inline |
Put the worker back to the availablity queue. If the worker process is dead, try replace with a new worker process. If a new worker process cannot be started, decrease the pool size.
Definition at line 321 of file worker_pool.hpp.