645#ifdef FLOW_DOXYGEN_ONLY
656# define FLOW_ASYNC_HW_THREAD_AFFINITY_PTHREAD_VIA_CORE_IDX
668# define FLOW_ASYNC_HW_THREAD_AFFINITY_MACH_VIA_POLICY_TAG
675# define FLOW_ASYNC_HW_THREAD_AFFINITY_PTHREAD_VIA_CORE_IDX 0
676# define FLOW_ASYNC_HW_THREAD_AFFINITY_MACH_VIA_POLICY_TAG 1
677# elif defined(FLOW_OS_LINUX)
678# define FLOW_ASYNC_HW_THREAD_AFFINITY_PTHREAD_VIA_CORE_IDX 1
679# define FLOW_ASYNC_HW_THREAD_AFFINITY_MACH_VIA_POLICY_TAG 0
681# error "We only know how to deal with thread-core affinities in Darwin/Mac and Linux."
690template<
typename Handler>
695 return [loop, op, handler = std::move(handler)](
auto... params)
mutable
698 [handler = std::move(handler),
The core flow::async interface, providing an optionally multi-threaded thread pool onto which runnabl...
virtual size_t n_threads() const =0
How many threads does start() start?
virtual void post(Task &&task, Synchronicity synchronicity=Synchronicity::S_ASYNC)=0
Cause the given Task (function) to execute within the thread pool as soon as possible,...
virtual Op create_op()=0
Return a new Op which can bundle together an arbitrary set of post()s that would result in the provid...
virtual const Op_list & per_thread_ops()=0
Returns the optional-use, pre-created collection of per-thread async::Op objects, such that the i-th ...
~Concurrent_task_loop() override
Any implementing subclass's destructor shall execute stop() – see its doc header please – and then cl...
Function< void(size_t thread_idx)> Thread_init_func
Short-hand for the thread-initializer-function optional arg type to start().
virtual void stop()=0
Waits for any ongoing task(s)/completion handler(s) to return; then prevents any further-queued such ...
virtual void post(const Op &op, Task &&task, Synchronicity synchronicity=Synchronicity::S_ASYNC)=0
Identical to the other post() with the added constraint that no other Task also similarly posted with...
virtual util::Scheduled_task_handle schedule_at(const Op &op, const Fine_time_pt &at, Scheduled_task &&task)=0
Equivalent to 3-argument schedule_from_now() except one specifies an absolute time point instead of w...
virtual Task_engine_ptr task_engine()=0
Returns a pointer to an internal util::Task_engine (a/k/a boost.asio io_service) for the purpose of p...
virtual util::Scheduled_task_handle schedule_from_now(const Fine_duration &from_now, Scheduled_task &&task)=0
Equivalent to 2-argument post() but execution is scheduled for later, after the given time period pas...
virtual util::Scheduled_task_handle schedule_at(const Fine_time_pt &at, Scheduled_task &&task)=0
Equivalent to 2-argument schedule_from_now() except one specifies an absolute time point instead of w...
virtual util::Scheduled_task_handle schedule_from_now(const Op &op, const Fine_duration &from_now, Scheduled_task &&task)=0
Equivalent to 3-argument post() but execution is scheduled for later, after the given time period pas...
virtual void start(Task &&init_task_or_empty=Task(), const Thread_init_func &thread_init_func_or_empty=Thread_init_func())=0
Starts all threads in the thread pool; any queued post()ed (and similar) tasks may begin executing im...
Simple, immutable vector-like sequence of N opaque async::Op objects, usually corresponding to N work...
An empty interface, consisting of nothing but a default virtual destructor, intended as a boiler-plat...
Flow module containing tools enabling multi-threaded event loops operating under the asynchronous-tas...
boost::any Op
An object of this opaque type represents a collection of 1 or more async::Task, past or future,...
Synchronicity
Enumeration indicating the manner in which asio_exec_ctx_post(), and various boost....
@ S_ASYNC
Simply post the given task to execute asynchronously in some execution context – as soon as the conte...
@ S_OPPORTUNISTIC_SYNC_ELSE_ASYNC
Execute the given task synchronously, if the scheduler determines that the calling thread is in its t...
boost::shared_ptr< util::Task_engine > Task_engine_ptr
Short-hand for reference-counting pointer to a mutable util::Task_engine (a/k/a boost::asio::io_servi...
Function< void()> Task
Short-hand for a task that can be posted for execution by a Concurrent_task_loop or flow::util::Task_...
auto asio_handler_via_op(Concurrent_task_loop *loop, const Op &op, Handler &&handler)
Given a boost.asio completion handler handler for a boost.asio async_*() action on some boost....
boost::shared_ptr< Scheduled_task_handle_state > Scheduled_task_handle
Black-box type that represents a handle to a scheduled task as scheduled by schedule_task_at() or sch...
Fine_clock::duration Fine_duration
A high-res time duration as computed from two Fine_time_pts.
Fine_clock::time_point Fine_time_pt
A high-res time point as returned by Fine_clock::now() and suitable for precise time math in general.