Flow 1.0.1
Flow project: Public API.
Namespaces | Typedefs | Enumerations | Functions
async_fwd.hpp File Reference

Namespaces

namespace  flow
 Catch-all namespace for the Flow project: A collection of various production-quality modules written in modern C++17, originally by ygoldfel.
 
namespace  flow::async
 Flow module containing tools enabling multi-threaded event loops operating under the asynchronous-task proactor pattern, by providing a streamlined API around boost.asio event loops with added advanced task- and thread-scheduling features.
 

Typedefs

using flow::async::Task = Function< void()>
 Short-hand for a task that can be posted for execution by a Concurrent_task_loop or flow::util::Task_engine; it is simply something callable via () with no arguments and returning nothing. More...
 
using flow::async::Op = boost::any
 An object of this opaque type represents a collection of 1 or more async::Task, past or future, such that: if one performs C->post(J, F) and C->post(K, G) (where C is Concurrent_task_loop*, JK are the same async::Op&, or one refers to a transitive copy of the other, and FG are both Tasks), then F and G will NOT execute concurrently. More...
 
using flow::async::Scheduled_task = util::Scheduled_task
 Similar to flow::async::Task but used for scheduled-in-future tasks as opposed to to-be-run-ASAP tasks. More...
 
using flow::async::Task_asio_err = Function< void(const Error_code &)>
 Short-hand for a boost.asio completion handler: The minimal type, taking only a flow::Error_code a/k/a boost::system::error_code.
 
using flow::async::Task_asio_err_sz = Function< void(const Error_code &, size_t)>
 Short-hand for a boost.asio completion handler: The type that takes a size_t count of things successfully transferred usually.
 
using flow::async::Task_engine_ptr = boost::shared_ptr< util::Task_engine >
 Short-hand for reference-counting pointer to a mutable util::Task_engine (a/k/a boost::asio::io_service). More...
 
using flow::async::Strand_ptr = boost::shared_ptr< util::Strand >
 Short-hand for ref-counted pointer to util::Strand.
 

Enumerations

enum class  flow::async::Synchronicity { flow::async::S_ASYNC , flow::async::S_ASYNC_AND_AWAIT_CONCURRENT_COMPLETION , flow::async::S_ASYNC_AND_AWAIT_CONCURRENT_START , flow::async::S_OPPORTUNISTIC_SYNC_ELSE_ASYNC }
 Enumeration indicating the manner in which asio_exec_ctx_post(), and various boost.asio "post" operations like it or based on it, are to actually execute the given task in relation to when the "posting" routine, itself, returns control to its caller. More...
 

Functions

template<typename Execution_context >
void flow::async::asio_exec_ctx_post (log::Logger *logger_ptr, Execution_context *exec_ctx, Synchronicity synchronicity, Task &&task)
 An extension of boost.asio's post() and dispatch() free function templates, this free function template allows the user to more easily select the synchronicity behavior as the given task is posted onto the given execution context (util::Task_engine or util::Strand at least). More...
 
unsigned int flow::async::optimal_worker_thread_count_per_pool (flow::log::Logger *logger_ptr, bool est_hw_core_sharing_helps_algo)
 Assuming a planned thread pool will be receiving ~symmetrical load, and its UX-affecting (in particular, per-op latency-affecting) operations are largely between processor and RAM: Returns the # of threads to store in that pool for efficient performance. More...
 
void flow::async::optimize_pinning_in_thread_pool (flow::log::Logger *logger_ptr, const std::vector< util::Thread * > &threads_in_pool, bool est_hw_core_sharing_helps_algo, bool est_hw_core_pinning_helps_algo, bool hw_threads_is_grouping_collated)
 Assuming the same situation as documented for optimal_worker_thread_count_per_pool(), and that indeed the pool now contains that number of running threads: Attempts to optimize thread-core-pinning behavior in that pool for efficient performance. More...
 
template<typename Handler >
auto flow::async::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.asio I/O object to be initiated in the immediate near future, returns a wrapped handler with the same signature to be passed as the handler arg to that async_*() action, so that handler() will execute non-concurrently with other tasks in Op op. More...
 
template<typename Exec_ctx_ptr >
Exec_ctx_ptr flow::async::op_to_exec_ctx (Concurrent_task_loop *loop, const Op &op)
 Template specialization model for operation that obtains the underlying execution context, such as a util::Task_engine or util::Strand, stored in an async::Op generated by the given Concurrent_task_loop. More...
 
template<>
Task_engine_ptr flow::async::op_to_exec_ctx< Task_engine_ptr > (Concurrent_task_loop *loop, const Op &op)
 Template specialization for operation that obtains the underlying execution context, in this case a util::Task_engine, stored in an async::Op generated by the given Segregated_thread_task_loop. More...
 
template<>
Strand_ptr flow::async::op_to_exec_ctx< Strand_ptr > (Concurrent_task_loop *loop, const Op &op)
 Template specialization for operation that obtains the underlying execution context, in this case a util::Strand, stored in an async::Op generated by the given Cross_thread_task_loop. More...