Public Member Functions | List of all members
util::uring::ProactorPool Class Reference

Public Member Functions

 ProactorPool (const ProactorPool &)=delete
 
void operator= (const ProactorPool &)=delete
 
 ProactorPool (std::size_t pool_size=0)
 
void Run (uint32_t ring_depth=256)
 
void Stop ()
 Stops all io_context objects in the pool. More...
 
ProactorGetNextProactor ()
 Get a Proactor to use. Thread-safe.
 
Proactoroperator[] (size_t i)
 
Proactorat (size_t i)
 
size_t size () const
 
template<typename Func , AcceptArgsCheck< Func, Proactor * > = 0>
void AsyncOnAll (Func &&func)
 Runs func in all IO threads asynchronously. More...
 
template<typename Func , AcceptArgsCheck< Func, unsigned, Proactor * > = 0>
void AsyncOnAll (Func &&func)
 Runs func in all IO threads asynchronously. More...
 
template<typename Func , AcceptArgsCheck< Func, Proactor * > = 0>
void AwaitOnAll (Func &&func)
 Runs the funcion in all IO threads asynchronously. Blocks until all the asynchronous calls return. More...
 
template<typename Func , AcceptArgsCheck< Func, unsigned, Proactor * > = 0>
void AwaitOnAll (Func &&func)
 Blocks until all the asynchronous calls to func return. Func receives both the index and Proactor&. func must not block. More...
 
template<typename Func , AcceptArgsCheck< Func, unsigned, Proactor * > = 0>
void AsyncFiberOnAll (Func &&func)
 Runs func in a fiber asynchronously. func must accept Proactor&. func may fiber-block. More...
 
template<typename Func , AcceptArgsCheck< Func, Proactor * > = 0>
void AsyncFiberOnAll (Func &&func)
 Runs func in a fiber asynchronously. func must accept Proactor&. func may fiber-block. More...
 
template<typename Func , AcceptArgsCheck< Func, unsigned, Proactor * > = 0>
void AwaitFiberOnAll (Func &&func)
 Runs func wrapped in fiber on all IO threads in parallel. func must accept Proactor&. func may fiber-block. More...
 
template<typename Func , AcceptArgsCheck< Func, Proactor * > = 0>
void AwaitFiberOnAll (Func &&func)
 Runs func wrapped in fiber on all IO threads in parallel. func must accept Proactor*. func may fiber-block. More...
 
ProactorGetLocalProactor ()
 
absl::string_view GetString (absl::string_view source)
 

Detailed Description

Definition at line 21 of file proactor_pool.h.

Constructor & Destructor Documentation

◆ ProactorPool()

util::uring::ProactorPool::ProactorPool ( std::size_t  pool_size = 0)
explicit

Constructs io_context pool with number of threads equal to 'pool_size'. pool_size = 0 chooses automatically pool size equal to number of cores in the system.

Definition at line 19 of file proactor_pool.cc.

Member Function Documentation

◆ AsyncFiberOnAll() [1/2]

template<typename Func , AcceptArgsCheck< Func, unsigned, Proactor * > = 0>
void util::uring::ProactorPool::AsyncFiberOnAll ( Func &&  func)
inline

Runs func in a fiber asynchronously. func must accept Proactor&. func may fiber-block.

Parameters
func'func' callback runs inside a wrapping fiber.

Definition at line 141 of file proactor_pool.h.

◆ AsyncFiberOnAll() [2/2]

template<typename Func , AcceptArgsCheck< Func, Proactor * > = 0>
void util::uring::ProactorPool::AsyncFiberOnAll ( Func &&  func)
inline

Runs func in a fiber asynchronously. func must accept Proactor&. func may fiber-block.

Parameters
func'func' callback runs inside a wrapping fiber.

Definition at line 157 of file proactor_pool.h.

◆ AsyncOnAll() [1/2]

template<typename Func , AcceptArgsCheck< Func, Proactor * > = 0>
void util::uring::ProactorPool::AsyncOnAll ( Func &&  func)
inline

Runs func in all IO threads asynchronously.

The task must be CPU-only non IO-blocking code because it runs directly in IO-fiber. AsyncOnAll runs asynchronously and will exit before the task finishes. The 'func' must accept Proactor& as its argument.

Definition at line 71 of file proactor_pool.h.

◆ AsyncOnAll() [2/2]

template<typename Func , AcceptArgsCheck< Func, unsigned, Proactor * > = 0>
void util::uring::ProactorPool::AsyncOnAll ( Func &&  func)
inline

Runs func in all IO threads asynchronously.

The task must be CPU-only non IO-blocking code because it runs directly in IO-loop. AsyncOnAll runs asynchronously and will exit once func is submitted but before it has finished running. The 'func' must accept unsigned int (io context index) and Proactor& as its arguments.

Definition at line 89 of file proactor_pool.h.

◆ AwaitFiberOnAll() [1/2]

template<typename Func , AcceptArgsCheck< Func, unsigned, Proactor * > = 0>
void util::uring::ProactorPool::AwaitFiberOnAll ( Func &&  func)
inline

Runs func wrapped in fiber on all IO threads in parallel. func must accept Proactor&. func may fiber-block.

Parameters
funcWaits for all the callbacks to finish.

Definition at line 172 of file proactor_pool.h.

◆ AwaitFiberOnAll() [2/2]

template<typename Func , AcceptArgsCheck< Func, Proactor * > = 0>
void util::uring::ProactorPool::AwaitFiberOnAll ( Func &&  func)
inline

Runs func wrapped in fiber on all IO threads in parallel. func must accept Proactor*. func may fiber-block.

Parameters
funcWaits for all the callbacks to finish.

Definition at line 192 of file proactor_pool.h.

◆ AwaitOnAll() [1/2]

template<typename Func , AcceptArgsCheck< Func, Proactor * > = 0>
void util::uring::ProactorPool::AwaitOnAll ( Func &&  func)
inline

Runs the funcion in all IO threads asynchronously. Blocks until all the asynchronous calls return.

Func must accept "Proactor&" and it should not block.

Definition at line 105 of file proactor_pool.h.

◆ AwaitOnAll() [2/2]

template<typename Func , AcceptArgsCheck< Func, unsigned, Proactor * > = 0>
void util::uring::ProactorPool::AwaitOnAll ( Func &&  func)
inline

Blocks until all the asynchronous calls to func return. Func receives both the index and Proactor&. func must not block.

Definition at line 121 of file proactor_pool.h.

◆ Run()

void util::uring::ProactorPool::Run ( uint32_t  ring_depth = 256)

Starts running all Proactor objects in the pool. Blocks until all the proactors up and spinning.

Definition at line 36 of file proactor_pool.cc.

◆ Stop()

void util::uring::ProactorPool::Stop ( )

Stops all io_context objects in the pool.

Waits for all the threads to finish. Requires that Run has been called. Blocks the current thread until all the pool threads exited.

Definition at line 68 of file proactor_pool.cc.


The documentation for this class was generated from the following files: