Event Loop
PBMessageAppCreate
Structure:
Fields
window (owned PBWindow): Deprecated; do not use.
[in] argv (referenced array of referenced string):
PBMessageAppQuery
Structure:
Fields
[in] argv (referenced array of referenced string):
[in] writeStream (referenced PBStream):
PBMessageAppHandoff
Structure:
Fields
[in] window (referenced PBWindow):
[in] writeStream (referenced PBStream):
PBMessageAppCleanup
Structure:
Fields
unused (uint8_t
):
PBMessageAppSystemPropertyChanged
Structure:
Fields
index (PBSystemPropertyIndex):
newValue (double
):
PBApplicationMessageHandler
Callback:
Syntax (C/C++)
intptr_t PBApplicationMessageHandler(/* in-out */ PBMessage * __restrict message);
You can create a callback of this type from a function pointer with the above signature using PBApplicationMessageHandler_Make
.
Syntax (Python)
ApplicationMessageHandler(message) -> (result)
Parameters and Return Values
[in-out] message (PBMessage):
[out] result (intptr_t
):
PBRunAsEventCallback
Callback:
Syntax (C/C++)
void PBRunAsEventCallback();
You can create a callback of this type from a function pointer with the above signature using PBRunAsEventCallback_Make
.
Syntax (Python)
RunAsEventCallback()
PBEventLoop
Function:
Syntax (C/C++)
int32_t PBEventLoop(PBApplicationMessageHandler messageApplication);
Syntax (Python)
EventLoop(messageApplication) -> (unused)
Parameters and Return Values
[in] messageApplication (PBApplicationMessageHandler):
[out] unused (int32_t
):
Discussion
Run the application's event loop. This function never returns.
PBRunAsEvent
Function:
Syntax (C/C++)
bool PBRunAsEvent(PBRunAsEventCallback callback, bool waitForCompletion);
Syntax (Python)
RunAsEvent(callback, waitForCompletion) -> (success)
Parameters and Return Values
[in] callback (PBRunAsEventCallback):
[in] waitForCompletion (bool
):
[out] success (bool
):
PBRunAsEventC
C-only function:
Syntax (C)
bool PBRunAsEventC(void (*_Nullable callback)(void *_Nullable context), void (*_Nullable freeContext)(void *_Nullable context), void *_Nullable context, bool waitForCompletion)
PBEventSource
Opaque object handle:
This object maintains an internal reference count. When the reference count reaches zero, the object will be automatically deallocated. To increment the reference count, call PBEventSourceRetain; to decrement the reference count, call PBEventSourceRelease. These functions are thread-safe.
PBEventSourceFlags
Enumeration/bitset of type uint32_t:
Constants
PBEventSourceFlags_READ
PBEventSourceFlags_READ = 1<<0
PBEventSourceFlags_WRITE
PBEventSourceFlags_WRITE = 1<<1
PBEventSourceFlags_DISPATCH_OUTSIDE_UI_EVENT
PBEventSourceFlags_DISPATCH_OUTSIDE_UI_EVENT = 1<<2
For internal use only.
PBEventType
Enumeration/bitset of type uint32_t:
Constants
PBEventType_OTHER
PBEventType_OTHER = 0
PBEventType_READ
PBEventType_READ = 1
PBEventType_WRITE
PBEventType_WRITE = 2
PBEventType_ERROR
PBEventType_ERROR = 3
PBEventHandler
Callback:
Syntax (C/C++)
void PBEventHandler(PBEventSourceRef source, PBEventType eventType);
You can create a callback of this type from a function pointer with the above signature using PBEventHandler_Make
.
Syntax (Python)
EventHandler(source, eventType)
Parameters and Return Values
[in] source (referenced PBEventSource):
[in] eventType (PBEventType):
PBEventSourceCreateFromFD
Function:
Syntax (C/C++)
PBEventSourcePtr _Nullable PBEventSourceCreateFromFD(int32_t fileDescriptor,
bool takeOwnership);
Syntax (Python)
EventSourceCreateFromFD(fileDescriptor, takeOwnership) -> (source)
Parameters and Return Values
[in] fileDescriptor (int32_t
):
[in] takeOwnership (bool
):
[out] source (nullable owned PBEventSource):
Discussion
If takeOwnership is true and the call fails (i.e., null is returned), the call will close the fileDescriptor.
It is highly recommended that takeOwnership is set to true, since the file descriptor must not be closed until the event source is destroyed.
PBEventSourceCreateTimer
Function:
Syntax (C/C++)
PBEventSourcePtr _Nullable PBEventSourceCreateTimer(uint32_t periodMs);
Syntax (Python)
EventSourceCreateTimer(periodMs) -> (source)
Parameters and Return Values
[in] periodMs (uint32_t
):
[out] source (nullable owned PBEventSource):
PBEventSourceIsActive
Function:
Syntax (C/C++)
bool PBEventSourceIsActive(PBEventSourceRef source);
Syntax (Python)
EventSourceIsActive(source) -> (isActive)
Parameters and Return Values
[in] source (referenced PBEventSource):
[out] isActive (bool
):
PBEventSourceActivate
Function:
Syntax (C/C++)
bool PBEventSourceActivate(PBEventSourceRef source);
Syntax (Python)
EventSourceActivate(source) -> (isActive)
Parameters and Return Values
[in] source (referenced PBEventSource):
[out] isActive (bool
):
Discussion
This function must be called on the thread that is processing the event loop.
PBEventSourceDeactivate
Function:
Syntax (C/C++)
void PBEventSourceDeactivate(PBEventSourceRef source);
Syntax (Python)
EventSourceDeactivate(source)
Parameters and Return Values
[in] source (referenced PBEventSource):
Discussion
This function must be called on the thread that is processing the event loop. This function does nothing if the source has already been deactivated.
PBEventSourceSetFlags
Function:
Syntax (C/C++)
void PBEventSourceSetFlags(PBEventSourceRef source, PBEventSourceFlags flags);
Syntax (Python)
EventSourceSetFlags(source, flags)
Parameters and Return Values
[in] source (referenced PBEventSource):
[in] flags (PBEventSourceFlags):
PBEventSourceSetHandler
Function:
Syntax (C/C++)
void PBEventSourceSetHandler(PBEventSourceRef source, PBEventHandler handler);
Syntax (Python)
EventSourceSetHandler(source, handler)
Parameters and Return Values
[in] source (referenced PBEventSource):
[in] handler (PBEventHandler):
PBEventSourceSetUserDataInt
Function:
Syntax (C/C++)
void PBEventSourceSetUserDataInt(PBEventSourceRef source, int64_t integer);
Syntax (Python)
EventSourceSetUserDataInt(source, integer)
Parameters and Return Values
[in] source (referenced PBEventSource):
[in] integer (int64_t
):
PBEventSourceSetUserDataPtr
Function:
Syntax (C/C++)
void PBEventSourceSetUserDataPtr(PBEventSourceRef source,
void *_Nullable pointer);
Syntax (Python)
EventSourceSetUserDataPtr(source, pointer)
Parameters and Return Values
[in] source (referenced PBEventSource):
[in] pointer (opaque pointer):
PBEventSourceSetUserDataPtrWithOwnership
Function:
Syntax (C/C++)
void PBEventSourceSetUserDataPtrWithOwnership(PBEventSourceRef source,
void *_Nullable pointer);
Syntax (Python)
EventSourceSetUserDataPtrWithOwnership(source, pointer)
Parameters and Return Values
[in] source (referenced PBEventSource):
[in] pointer (opaque pointer):
PBEventSourceGetUserDataInt
Function:
Syntax (C/C++)
int64_t PBEventSourceGetUserDataInt(PBEventSourceRef source);
Syntax (Python)
EventSourceGetUserDataInt(source) -> (integer)
Parameters and Return Values
[in] source (referenced PBEventSource):
[out] integer (int64_t
):
PBEventSourceGetUserDataPtr
Function:
Syntax (C/C++)
void *_Nullable PBEventSourceGetUserDataPtr(PBEventSourceRef source);
Syntax (Python)
EventSourceGetUserDataPtr(source) -> (pointer)
Parameters and Return Values
[in] source (referenced PBEventSource):
[out] pointer (opaque pointer):
PBEventSourceGetTimeSincePreviousEvent
Function:
Syntax (C/C++)
double PBEventSourceGetTimeSincePreviousEvent(PBEventSourceRef source);
Syntax (Python)
EventSourceGetTimeSincePreviousEvent(source) -> (timeInSeconds)
Parameters and Return Values
[in] source (referenced PBEventSource):
[out] timeInSeconds (double
):
Discussion
This can only be called during the event handler of the specified source. If there is no event between the current event and the most recent activation of the source, then this returns the time since activation.