Caches objects of type T that are bound to an EventBase from the global IOExecutor.
Declared in <folly/executors/IOObjectCache.h>
template<class T>
class IOObjectCache;
Provide a factory that creates T objects given an EventBase, and get() will lazily create T objects based on an EventBase from the global IOExecutor. These are stored thread locally: for a given pair of event base and calling thread there will only be one T object created.
The primary use case is for managing objects that need to do async IO on an event base (e.g. thrift clients) that can be used outside the IO thread without much hassle. For instance, you could use this to manage Thrift clients that are only ever called from within other threads without the calling thread needing to know anything about the IO threads that the clients will do their work on.
| Name | Description |
|---|---|
TFactory | Factory that creates a T object bound to a given EventBase. |
| Name | Description |
|---|---|
IOObjectCache [constructor] | Constructors |
get | Return the cached object for the current thread and IO event base. |
setFactory | Set the factory used to create cached objects. |
| Name | Description |
|---|---|
| T | The type of object cached per EventBase. |