|
Robot Raconteur Core C++ Library
|
Thread pool for use with an external boost::asio::io_context and thread pool. More...
#include <ThreadPool.h>
Public Member Functions | |
| IOContextThreadPool (const boost::shared_ptr< RobotRaconteurNode > &node, boost::asio::io_context &external_io_context, bool multithreaded) | |
| Construct an IOContextThreadPool. | |
| RR_OVIRTUAL size_t | GetThreadPoolCount () RR_OVERRIDE |
| Returns 1 if single threaded, 2 if multithreaded. | |
| RR_OVIRTUAL void | SetThreadPoolCount (size_t count) RR_OVERRIDE |
| Invalid for IOContextThreadPool, throws InvalidOperationException. | |
| RR_OVIRTUAL void | Post (boost::function< void()> function) RR_OVERRIDE |
| Post a function to be executed by the thread pool in a worker thread and return immediately. | |
| RR_OVIRTUAL bool | TryPost (boost::function< void()> function) RR_OVERRIDE |
| Try posting a function to be executed by the thread pool in a worker thread and return immediately. | |
| RR_OVIRTUAL boost::asio::io_context & | get_io_context () RR_OVERRIDE |
| Get the boost::asio::io_context object. | |
Thread pool for use with an external boost::asio::io_context and thread pool.
Users may need to integrate Robot Raconteur with an external thread pool, single threaded environment, or an existing boost::asio::io_context. The IOContextThreadPool allows the use of the external thread pool. See threading for more information on the use of threading.
The IOContextThreadPool is used either with a thread pool or a single thread. If used with a single thread, the multithreaded argument in the constructor must be false. Blocking functions may not be used when in single threaded operation.
| RobotRaconteur::IOContextThreadPool::IOContextThreadPool | ( | const boost::shared_ptr< RobotRaconteurNode > & | node, |
| boost::asio::io_context & | external_io_context, | ||
| bool | multithreaded ) |
Construct an IOContextThreadPool.
Must use boost::make_shared<IOContextThreadpool>()
| node | The node that owns the thread pool |
| external_io_context | |
| multithreaded |
|
virtual |
Get the boost::asio::io_context object.
Use the returned boost::asio::io_context reference to initialize Boost.Asio objects
Reimplemented from RobotRaconteur::ThreadPool.
|
virtual |
Returns 1 if single threaded, 2 if multithreaded.
Reimplemented from RobotRaconteur::ThreadPool.
|
virtual |
Post a function to be executed by the thread pool in a worker thread and return immediately.
| function | The function to execute |
Reimplemented from RobotRaconteur::ThreadPool.
|
virtual |
Invalid for IOContextThreadPool, throws InvalidOperationException.
The IOContextThreadPool does not control the number of threads
| count |
Reimplemented from RobotRaconteur::ThreadPool.
|
virtual |
Try posting a function to be executed by the thread pool in a worker thread and return immediately.
| function | The function to execute |
Reimplemented from RobotRaconteur::ThreadPool.