Fcitx
Public Member Functions | Static Public Member Functions | List of all members
fcitx::EventLoop Class Reference

Public Member Functions

 EventLoop (std::unique_ptr< EventLoopInterface > impl)
 
bool exec ()
 
void exit ()
 
const char * implementation () const
 Return the name of implementation of event loop. More...
 
void * nativeHandle ()
 
FCITX_NODISCARD std::unique_ptr< EventSourceIOaddIOEvent (int fd, IOEventFlags flags, IOCallback callback)
 
FCITX_NODISCARD std::unique_ptr< EventSourceTimeaddTimeEvent (clockid_t clock, uint64_t usec, uint64_t accuracy, TimeCallback callback)
 
FCITX_NODISCARD std::unique_ptr< EventSourceaddExitEvent (EventCallback callback)
 
FCITX_NODISCARD std::unique_ptr< EventSourceaddDeferEvent (EventCallback callback)
 
FCITX_NODISCARD std::unique_ptr< EventSourceaddPostEvent (EventCallback callback)
 
FCITX_NODISCARD std::unique_ptr< EventSourceAsyncaddAsyncEvent (EventCallback callback)
 Add an async event that is safe to be triggered from another thread. More...
 

Static Public Member Functions

static FCITXUTILS_DEPRECATED const char * impl ()
 Return the default implementation name. More...
 
static void setEventLoopFactory (EventLoopFactory factory)
 Set an external event loop implementation. More...
 

Detailed Description

Definition at line 23 of file event.h.

Member Function Documentation

◆ addAsyncEvent()

std::unique_ptr< EventSourceAsync > fcitx::EventLoop::addAsyncEvent ( EventCallback  callback)

Add an async event that is safe to be triggered from another thread.

To ensure safe usage of this event:

  1. Do not change event to disable, if there may be pending call to send()
  2. Due to (1), if it is oneshot, ensure you only call send() once.
  3. Join all the possible pending thread that may call send(), before destructing the event.
  4. Like other event, the event should be only created/destructed on the event loop thread.

EventDispatcher uses this event internally and provides an easier and safer interface to use.

See also
EventDispatcher
Parameters
callbackcallback function
Returns
async event source
Since
5.1.13

Definition at line 104 of file event.cpp.

◆ impl()

const char * fcitx::EventLoop::impl ( )
static

Return the default implementation name.

This will only return the default implementation name. Do not rely on this value.

See also
EventLoop::implementation

Definition at line 53 of file event.cpp.

◆ implementation()

const char * fcitx::EventLoop::implementation ( ) const

Return the name of implementation of event loop.

Since
5.1.12

Definition at line 55 of file event.cpp.

◆ setEventLoopFactory()

void fcitx::EventLoop::setEventLoopFactory ( EventLoopFactory  factory)
static

Set an external event loop implementation.

This is useful if you need to integrate fcitx with another event loop.

Since
5.1.12

Definition at line 38 of file event.cpp.


The documentation for this class was generated from the following files: