Public Member Functions | List of all members
util::fibers_ext::FiberQueue Class Reference

MPSC task-queue that is handled by a single consumer loop. More...

#include <fiberqueue_threadpool.h>

Public Member Functions

 FiberQueue (unsigned queue_size=128)
 
template<typename F >
bool TryAdd (F &&f)
 
template<typename F >
bool Add (F &&f)
 Submits a callback into the queue. Should not be called after calling Shutdown(). More...
 
template<typename F >
auto Await (F &&f) -> decltype(f())
 Sends f to consumer thread and waits for it to finish runnning. More...
 
void Shutdown ()
 Notifies Run() function to empty the queue and to exit. Does not block.
 
void Run ()
 

Detailed Description

MPSC task-queue that is handled by a single consumer loop.

The loop is exposed as a function to incorporate into a thread or fiber of your choice.

Definition at line 20 of file fiberqueue_threadpool.h.

Member Function Documentation

◆ Add()

template<typename F >
bool util::fibers_ext::FiberQueue::Add ( F &&  f)
inline

Submits a callback into the queue. Should not be called after calling Shutdown().

Template Parameters
F- callback type
Parameters
f- callback object
Returns
true if Add() had to preempt, false is fast path without preemptions was followed.

Definition at line 42 of file fiberqueue_threadpool.h.

◆ Await()

template<typename F >
auto util::fibers_ext::FiberQueue::Await ( F &&  f) -> decltype(f())
inline

Sends f to consumer thread and waits for it to finish runnning.

Template Parameters
F
Parameters
f- a callback
Returns
decltype(f())

Definition at line 67 of file fiberqueue_threadpool.h.


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