dragon.native.event

The Dragon native event is an object that is used for signaling between threads or processes.

One thread or process signals an event and the other waits. When the waiting thread is signalled, the waiting thread is activated.

Classes

Event

This class implements Event objects with a Dragon channel.

class Event

Bases: object

This class implements Event objects with a Dragon channel. The event sends and receives bytes of the message with the respective functions set and clear. Wait is the function that waits for bytes to be written into the channel

__init__(m_uid: int = 4611686018427387904)

Initialize an event object :param m_uid: memory pool to create the channel in, defaults to _DEF_MUID :type m_uid: int, optional

set() None

Set the event.

Set writes a messsage into the channel.

Returns:

None

Return type:

NoneType

is_set() bool

Returns if the event has been set. Polls the channel for the message.

Returns:

Results from a channel poll with a timeout set to 0.

Return type:

bool

wait(timeout: float | None = None) bool

Wait for the timeout to elapse and poll for the message in the channel.

Parameters:

timeout (float, optional) – how long to block in seconds, defaults to None

Returns:

if the event has been set

Return type:

bool

clear() None

Clears the event once the message from the channel has been received.

Clear receives a messsage from the channel

Returns:

None

Return type:

NoneType

destroy()

Destroys the underlying Dragon resources so the space can be re-used.

Destroys underlying Dragon resource. Only do this when you know all references to the object have been deleted.

Returns:

None

Return type:

NoneType