|
drogon
C++14/17-based HTTP application framework
|
Utility class for thread storage handling. More...
#include <drogon/IOThreadStorage.h>


Public Types | |
| using | ValueType = C |
| using | InitCallback = std::function<void(ValueType &, size_t)> |
Public Member Functions | |
| template<typename... Args> | |
| IOThreadStorage (Args &&...args) | |
| void | init (const InitCallback &initCB) |
| ValueType & | getThreadData () |
| Get the thread storage associate with the current thread. | |
| const ValueType & | getThreadData () const |
| void | setThreadData (const ValueType &newData) |
| Sets the thread data for the current thread. | |
| void | setThreadData (ValueType &&newData) |
| ValueType * | operator-> () |
| ValueType & | operator* () |
| const ValueType * | operator-> () const |
| const ValueType & | operator* () const |
Utility class for thread storage handling.
Thread storage allows the efficient handling of reusable data without thread synchronisation. For instance, such a thread storage would be useful to store database connections.
Example usage:
|
inline |
Get the thread storage associate with the current thread.
This function may only be called in a request handler
|
inline |
Sets the thread data for the current thread.
This function may only be called in a request handler