![]() |
helics
2.8.1
|
#include <AsioContextManager.h>
Public Types | |
using | LoopHandle = std::unique_ptr< Servicer > |
Public Member Functions | |
const std::string & | getName () const |
asio::io_context & | getBaseContext () const |
LoopHandle | startContextLoop () |
bool | isRunning () const |
Static Public Member Functions | |
static std::shared_ptr< AsioContextManager > | getContextPointer (const std::string &contextName=std::string()) |
static std::shared_ptr< AsioContextManager > | getExistingContextPointer (const std::string &contextName=std::string()) |
static asio::io_context & | getContext (const std::string &contextName=std::string()) |
static asio::io_context & | getExistingContext (const std::string &contextName=std::string()) |
static void | closeContext (const std::string &contextName=std::string()) |
static void | setContextToLeakOnDelete (const std::string &contextName=std::string()) |
static LoopHandle | runContextLoop (const std::string &contextName=std::string{}) |
Friends | |
void | contextProcessingLoop (std::shared_ptr< AsioContextManager > ptr) |
class defining a (potential) singleton Asio io_context manager for all asio usage
|
inline |
get the underlying asio::io_context reference
Referenced by startContextLoop().
|
static |
get the asio io_context associated with the context manager
References getContextPointer().
|
static |
return a pointer to a context manager
the function will search for an existing context manager for the name if it doesn't find one it will create a new one
contextName | the name of the context to find or create |
Referenced by getContext(), helics::getLocalExternalAddressV4(), and helics::getLocalExternalAddressV6().
|
static |
get the asio io_context associated with the context manager but only if the context exists if it doesn't this will throw and invalid_argument exception
References getExistingContextPointer().
|
static |
return a pointer to a context manager
the function will search for an existing context manager for the name if it doesn't find one it will return nullptr
contextName | the name of the context to find |
Referenced by getExistingContext().
|
inline |
get the name of the current context manager
|
inline |
check if the contextLoopo is running
|
static |
run a single thread for the context manager to execute asynchronous contexts in
will run a single thread for the io_context, it will not stop the thread until either the context manager is closed or the haltContextLoop function is called and there is no more work
contextName | the name of the context |
|
static |
tell the context to free the pointer and leak the memory on delete
You may ask why, well in windows systems when operating in a DLL if this context is closed after certain other operations that happen when the DLL is unlinked bad things can happen, and since in nearly all cases this happens at Shutdown leaking really doesn't matter that much and if you don't the context could terminate before some other parts of the program which cause all sorts of odd errors and issues
AsioContextManager::LoopHandle AsioContextManager::startContextLoop | ( | ) |
run a single thread for the context manager to execute asynchronous contexts in
will run a single thread for the io_context, it will not stop the thread until either the context manager is closed or the haltContextLoop function is called and there is no more work
References getBaseContext().