proxygen
|
#include <EventBase.h>
Public Member Functions | |
EventBaseLocal () | |
T * | get (EventBase &evb) |
void | emplace (EventBase &evb, T *ptr) |
template<typename... Args> | |
void | emplace (EventBase &evb, Args &&...args) |
template<typename... Args> | |
T & | getOrCreate (EventBase &evb, Args &&...args) |
template<typename Func > | |
T & | getOrCreateFn (EventBase &evb, Func fn) |
Public Member Functions inherited from folly::detail::EventBaseLocalBase | |
EventBaseLocalBase () | |
~EventBaseLocalBase () override | |
void | erase (EventBase &evb) |
void | onEventBaseDestruction (EventBase &evb) override |
Public Member Functions inherited from folly::detail::EventBaseLocalBaseBase | |
virtual | ~EventBaseLocalBaseBase ()=default |
Additional Inherited Members | |
Protected Member Functions inherited from folly::detail::EventBaseLocalBase | |
void | setVoid (EventBase &evb, std::shared_ptr< void > &&ptr) |
void * | getVoid (EventBase &evb) |
Protected Attributes inherited from folly::detail::EventBaseLocalBase | |
folly::Synchronized< std::unordered_set< EventBase * > > | eventBases_ |
std::size_t | key_ {keyCounter_++} |
Static Protected Attributes inherited from folly::detail::EventBaseLocalBase | |
static std::atomic< std::size_t > | keyCounter_ {0} |
A storage abstraction for data that should be tied to an EventBase.
struct Foo { Foo(int a, int b); }; EventBaseLocal<Foo> myFoo; ... EventBase evb; myFoo.set(evb, new Foo(1, 2)); myFoo.set(evb, 1, 2); Foo* foo = myFoo.get(evb); myFoo.erase(evb); Foo& foo = myFoo.getOrCreate(evb, 1, 2); // ctor Foo& foo = myFoo.getOrCreate(evb, 1, 2); // no ctor myFoo.erase(evb); Foo& foo = myFoo.getOrCreateFn(evb, [] () { return new Foo(3, 4); })
The objects will be deleted when the EventBaseLocal or the EventBase is destructed (whichever comes first). All methods must be called from the EventBase thread.
The user is responsible for throwing away invalid references/ptrs returned by the get() method after set/erase is called. If shared ownership is needed, use a EventBaseLocal<shared_ptr<...>>.
Definition at line 68 of file EventBase.h.
|
inline |
Definition at line 76 of file EventBaseLocal.h.
|
inline |
Definition at line 82 of file EventBaseLocal.h.
References testing::Args(), folly::gen::move, and folly::detail::EventBaseLocalBase::setVoid().
Referenced by TEST().
|
inline |
Definition at line 88 of file EventBaseLocal.h.
References testing::Args(), and folly::detail::EventBaseLocalBase::setVoid().
|
inline |
Definition at line 78 of file EventBaseLocal.h.
References folly::detail::EventBaseLocalBase::getVoid(), and folly::T.
Referenced by TEST().
|
inline |
Definition at line 94 of file EventBaseLocal.h.
References folly::detail::EventBaseLocalBase::getVoid(), folly::gen::move, ptr, folly::detail::EventBaseLocalBase::setVoid(), and folly::T.
Referenced by TEST().
|
inline |
Definition at line 105 of file EventBaseLocal.h.
References folly::detail::EventBaseLocalBase::getVoid(), folly::gen::move, ptr, folly::detail::EventBaseLocalBase::setVoid(), and folly::T.
Referenced by TEST().