qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
Classes | Public Slots | Public Member Functions | Static Protected Attributes | Private Member Functions | Private Attributes | List of all members
IPC Class Reference

Inter-process communication. More...

#include <ipc.h>

Inheritance diagram for IPC:
Inheritance graph
Collaboration diagram for IPC:
Collaboration graph

Classes

struct  IPCEvent
 
struct  IPCMemory
 

Public Slots

void setProfileId (uint32_t profileId)
 

Public Member Functions

 IPC (uint32_t profileId)
 
 ~IPC ()
 
time_t postEvent (const QString &name, const QByteArray &data=QByteArray(), uint32_t dest=0)
 Post IPC event. More...
 
bool isCurrentOwner ()
 
void registerEventHandler (const QString &name, IPCEventHandler handler)
 Register a handler for an IPC event. More...
 
bool isEventAccepted (time_t time)
 
bool waitUntilAccepted (time_t time, int32_t timeout=-1)
 
bool isAttached () const
 

Static Protected Attributes

static const int EVENT_TIMER_MS = 1000
 
static const int EVENT_GC_TIMEOUT = 5
 
static const int EVENT_QUEUE_SIZE = 32
 
static const int OWNERSHIP_TIMEOUT_S = 5
 

Private Member Functions

IPCMemoryglobal ()
 
bool runEventHandler (IPCEventHandler handler, const QByteArray &arg)
 
IPCEventfetchEvent ()
 Only called when global memory IS LOCKED. More...
 
void processEvents ()
 
bool isCurrentOwnerNoLock ()
 Only called when global memory IS LOCKED. More...
 

Private Attributes

QTimer timer
 
uint64_t globalId
 
uint32_t profileId
 
QSharedMemory globalMemory
 
QMap< QString, IPCEventHandlereventHandlers
 

Detailed Description

Inter-process communication.

Definition at line 34 of file ipc.h.

Constructor & Destructor Documentation

◆ IPC()

IPC::IPC ( uint32_t  profileId)

Definition at line 72 of file ipc.cpp.

◆ ~IPC()

IPC::~IPC ( )

Definition at line 116 of file ipc.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ fetchEvent()

IPC::IPCEvent * IPC::fetchEvent ( )
private

Only called when global memory IS LOCKED.

Returns
nullptr if no evnts present, IPC event otherwise

Definition at line 249 of file ipc.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ global()

IPC::IPCMemory * IPC::global ( )
private

Definition at line 353 of file ipc.cpp.

Here is the caller graph for this function:

◆ isAttached()

bool IPC::isAttached ( ) const

Definition at line 235 of file ipc.cpp.

Here is the caller graph for this function:

◆ isCurrentOwner()

bool IPC::isCurrentOwner ( )

Definition at line 176 of file ipc.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCurrentOwnerNoLock()

bool IPC::isCurrentOwnerNoLock ( )
private

Only called when global memory IS LOCKED.

Returns
true if owner, false if not owner or if error

Definition at line 343 of file ipc.cpp.

Here is the caller graph for this function:

◆ isEventAccepted()

bool IPC::isEventAccepted ( time_t  time)

Definition at line 197 of file ipc.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ postEvent()

time_t IPC::postEvent ( const QString &  name,
const QByteArray &  data = QByteArray(),
uint32_t  dest = 0 
)

Post IPC event.

Parameters
nameName to set in IPC event.
dataData to set in IPC event (default QByteArray()).
destSettings::getCurrentProfileId() or 0 (main instance, default).
Returns
Time the event finished or 0 on error.

Definition at line 136 of file ipc.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processEvents()

void IPC::processEvents ( )
private

Definition at line 286 of file ipc.cpp.

Here is the call graph for this function:

◆ registerEventHandler()

void IPC::registerEventHandler ( const QString &  name,
IPCEventHandler  handler 
)

Register a handler for an IPC event.

Parameters
handlerThe handler callback. Should not block for more than a second, at worst

Definition at line 192 of file ipc.cpp.

◆ runEventHandler()

bool IPC::runEventHandler ( IPCEventHandler  handler,
const QByteArray &  arg 
)
private

Definition at line 272 of file ipc.cpp.

Here is the caller graph for this function:

◆ setProfileId

void IPC::setProfileId ( uint32_t  profileId)
slot

Definition at line 240 of file ipc.cpp.

Here is the caller graph for this function:

◆ waitUntilAccepted()

bool IPC::waitUntilAccepted ( time_t  time,
int32_t  timeout = -1 
)

Definition at line 218 of file ipc.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ EVENT_GC_TIMEOUT

const int IPC::EVENT_GC_TIMEOUT = 5
staticprotected

Definition at line 40 of file ipc.h.

◆ EVENT_QUEUE_SIZE

const int IPC::EVENT_QUEUE_SIZE = 32
staticprotected

Definition at line 41 of file ipc.h.

◆ EVENT_TIMER_MS

const int IPC::EVENT_TIMER_MS = 1000
staticprotected

Definition at line 39 of file ipc.h.

◆ eventHandlers

QMap<QString, IPCEventHandler> IPC::eventHandlers
private

Definition at line 91 of file ipc.h.

◆ globalId

uint64_t IPC::globalId
private

Definition at line 88 of file ipc.h.

◆ globalMemory

QSharedMemory IPC::globalMemory
private

Definition at line 90 of file ipc.h.

◆ OWNERSHIP_TIMEOUT_S

const int IPC::OWNERSHIP_TIMEOUT_S = 5
staticprotected

Definition at line 42 of file ipc.h.

◆ profileId

uint32_t IPC::profileId
private

Definition at line 89 of file ipc.h.

◆ timer

QTimer IPC::timer
private

Definition at line 87 of file ipc.h.


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