Fcitx
|
A thread safe class to post event to a certain EventLoop. More...
#include <fcitx-utils/eventdispatcher.h>
Public Member Functions | |
EventDispatcher () | |
Construct a new event dispatcher. More... | |
void | attach (EventLoop *event) |
Attach EventDispatcher to an EventLoop. More... | |
void | detach () |
Detach event dispatcher from event loop, must be called from the same thread from event loop. | |
void | schedule (std::function< void()> functor) |
A thread-safe function to schedule a functor to be call from event loop. More... | |
template<typename T > | |
void | scheduleWithContext (TrackableObjectReference< T > context, std::function< void()> functor) |
A helper function that allows to only invoke certain function if the reference is still valid. More... | |
EventLoop * | eventLoop () const |
Return the currently attached event loop. More... | |
A thread safe class to post event to a certain EventLoop.
Definition at line 26 of file eventdispatcher.h.
fcitx::EventDispatcher::EventDispatcher | ( | ) |
Construct a new event dispatcher.
May throw exception if it fails to create underlying file descriptor.
Definition at line 44 of file eventdispatcher.cpp.
void fcitx::EventDispatcher::attach | ( | EventLoop * | event | ) |
Attach EventDispatcher to an EventLoop.
Must be called in the same thread of EventLoop.
event | event loop to attach to. |
Definition at line 49 of file eventdispatcher.cpp.
EventLoop * fcitx::EventDispatcher::eventLoop | ( | ) | const |
Return the currently attached event loop.
Definition at line 79 of file eventdispatcher.cpp.
void fcitx::EventDispatcher::schedule | ( | std::function< void()> | functor | ) |
A thread-safe function to schedule a functor to be call from event loop.
If functor is null, it will simply wake up event loop. Passing null can be useful if you want to implement your own event loop and wake up event loop.
functor | functor to be called. |
Definition at line 66 of file eventdispatcher.cpp.
|
inline |
A helper function that allows to only invoke certain function if the reference is still valid.
If context object is not valid when calling scheduleWithContext, it won't be scheduled at all.
context | the context object. |
functor | function to be scheduled |
Definition at line 73 of file eventdispatcher.h.