boost::corosio::select_context
I/O context using POSIX select() for event multiplexing.
Synopsis
Declared in <boost/corosio/select_context.hpp>
class select_context
: public basic_io_context
Description
This context provides an execution environment for async operations using the POSIX select() API for I/O event notification. It is available on all POSIX platforms and provides a portable fallback when more efficient platform‐specific APIs (epoll, kqueue) are not available or when explicit portability is desired.
On Linux, both epoll_context and select_context are available, allowing users to choose at runtime:
epoll_context ctx1; // Use epoll (best performance)
select_context ctx2; // Use select (portable, useful for testing)
Known Limitations
‐ FD_SETSIZE (~1024) limits maximum concurrent connections ‐ O(n) scanning: rebuilds fd_sets each iteration ‐ Level‐triggered only (no edge‐triggered mode)
Thread Safety
Distinct objects: Safe. Shared objects: Safe, if using a concurrency hint greater than 1.
Example
select_context ctx;
auto ex = ctx.get_executor();
run_async(ex)(my_coroutine());
ctx.run(); // Process all queued work
Types
Name |
Description |
The executor type for this context. |
|
Abstract base class for services owned by an execution context. |
Member Functions
Name |
Description |
|
Constructors |
|
Destructor. |
|
Assignment operators |
Return a pointer to the service of type T, or nullptr. |
|
Return an executor for this context. |
|
Return the memory resource used for coroutine frame allocation. |
|
Return true if a service of type T exists. |
|
Construct and add a service. |
|
Process all ready work items without blocking. |
|
Process at most one ready work item without blocking. |
|
Restart the context after being stopped. |
|
Process all pending work items. |
|
Process work items for the specified duration. |
|
Process at most one pending work item. |
|
Process at most one work item for the specified duration. |
|
Process at most one work item until the specified time. |
|
Process work items until the specified time. |
|
|
|
Signal the context to stop processing. |
|
Return whether the context has been stopped. |
|
Return a reference to the service of type T, creating it if needed. |
Protected Data Members
Name |
Created with MrDocs