Provides a mechanism for sending one or more messages to a messenger at a specified interval and receive reply messages. More...
Public Member Functions | |
BMessageRunner (BMessenger target, const BMessage &message, bigtime_t interval, int32 count, BMessenger replyTo) | |
Creates and initializes a new BMessageRunner and instructs the system roster to send the specified message to the target count times every interval microseconds. | |
BMessageRunner (BMessenger target, const BMessage &message, bigtime_t interval, int32 count=-1) | |
Creates and initializes a new BMessageRunner and instructs the system roster to send the specified message to the target count times every interval microseconds, reply messages are sent to be_app_messenger . | |
BMessageRunner (BMessenger target, const BMessage *message, bigtime_t interval, int32 count, BMessenger replyTo) | |
Creates and initializes a new BMessageRunner and instructs the system roster to send the specified message to the target count times every interval microseconds. | |
BMessageRunner (BMessenger target, const BMessage *message, bigtime_t interval, int32 count=-1) | |
Creates and initializes a new BMessageRunner and instructs the system roster to send the specified message to the target count times every interval microseconds, reply messages are sent to be_app_messenger . | |
virtual | ~BMessageRunner () |
Frees all resources associated with the object. | |
status_t | GetInfo (bigtime_t *interval, int32 *count) const |
Returns the time interval between two messages and the number of times the message has still to be sent. | |
status_t | InitCheck () const |
Returns the initialization status. | |
status_t | SetCount (int32 count) |
Sets the number of times message should be sent. | |
status_t | SetInterval (bigtime_t interval) |
Sets the interval of time between messages. | |
Static Public Member Functions | |
static status_t | StartSending (BMessenger target, const BMessage *message, bigtime_t interval, int32 count) |
Creates and initializes a detached BMessageRunner and instructs the system roster to send the specified message to the target count times every interval microseconds, reply messages are sent to be_app_messenger . | |
static status_t | StartSending (BMessenger target, const BMessage *message, bigtime_t interval, int32 count, BMessenger replyTo) |
Creates and initializes a detached BMessageRunner and instructs the system roster to send the specified message to the target count times every interval microseconds. | |
Provides a mechanism for sending one or more messages to a messenger at a specified interval and receive reply messages.
The application that creates the BMessageRunner can specify the message, the BMessenger to send the message to, how often to send the message, how many times to send the message, and the BMessenger to send reply messages from.
The system roster handles dispatching the messages to the appropriate messengers at the specified time intervals. The target for any reply messages is be_app_messenger
by default, or it can be specified in the constructor.
After initializing a BMessageRunner, the initialization can and should be checked by calling InitCheck(). BMessageRunner will not take ownership of the message, you may freely change or delete the message after initialization.
The BMessageRunner can be reconfigured (to change the interval or count) by calling SetInterval() and SetCount(). This is useful if you want to stop a BMessageRunner from sending messages early or if messages are set to be sent forever.
BMessageRunner::BMessageRunner | ( | BMessenger | target, |
const BMessage * | message, | ||
bigtime_t | interval, | ||
int32 | count = -1 |
||
) |
Creates and initializes a new BMessageRunner and instructs the system roster to send the specified message to the target count times every interval microseconds, reply messages are sent to be_app_messenger
.
target | The target of the message(s). |
message | The message to be sent to the target. |
interval | Period of time before the first message is sent and between messages (if more than one shall be sent) in microseconds. |
count | Specifies how many times the message shall be sent. A negative value indicates that the message will be sent forever, or until the BMessageRunner is reconfigured or deleted. |
BMessageRunner::BMessageRunner | ( | BMessenger | target, |
const BMessage & | message, | ||
bigtime_t | interval, | ||
int32 | count = -1 |
||
) |
Creates and initializes a new BMessageRunner and instructs the system roster to send the specified message to the target count times every interval microseconds, reply messages are sent to be_app_messenger
.
target | Target of the message(s). |
message | The message to be sent to the target. |
interval | Period of time before the first message is sent and between messages (if more than one shall be sent) in microseconds. |
count | Specifies how many times the message shall be sent. A negative value indicates that the message will be sent forever, or until the BMessageRunner is reconfigured or deleted. |
BMessageRunner::BMessageRunner | ( | BMessenger | target, |
const BMessage * | message, | ||
bigtime_t | interval, | ||
int32 | count, | ||
BMessenger | replyTo | ||
) |
Creates and initializes a new BMessageRunner and instructs the system roster to send the specified message to the target count times every interval microseconds.
This constructor also allows you to specify the target for replies to the delivered messages.
target | Target of the message(s). |
message | The message to be sent to the target. |
interval | Period of time before the first message is sent and between messages (if more than one shall be sent) in microseconds. |
count | Specifies how many times the message shall be sent. A negative value indicates that the message will be sent forever, or until the BMessageRunner is reconfigured or deleted. |
replyTo | Target replies to the delivered message(s) shall be sent to. |
BMessageRunner::BMessageRunner | ( | BMessenger | target, |
const BMessage & | message, | ||
bigtime_t | interval, | ||
int32 | count, | ||
BMessenger | replyTo | ||
) |
Creates and initializes a new BMessageRunner and instructs the system roster to send the specified message to the target count times every interval microseconds.
This constructor also allows you to specify the target for replies to the delivered messages.
target | Target of the message(s). |
message | The message to be sent to the target. |
interval | Period of time before the first message is sent and between messages (if more than one shall be sent) in microseconds. |
count | Specifies how many times the message shall be sent. A negative value indicates that the message will be sent forever, or until the BMessageRunner is reconfigured or deleted. |
replyTo | Target replies to the delivered message(s) shall be sent to. |
|
virtual |
Frees all resources associated with the object.
Returns the time interval between two messages and the number of times the message has still to be sent.
Both parameters (interval and count) may be NULL
.
interval | Pointer to a pre-allocated bigtime_t variable to be set to the time interval. May be NULL . |
count | Pointer to a pre-allocated int32 variable to be set to the number of times the message has still to be sent. May be NULL . |
B_OK
on success or an error code otherwise. B_OK | Everything went fine. |
B_BAD_VALUE | interval was 0 or negative, or the message runner had already sent all messages and became unusable. |
status_t BMessageRunner::InitCheck | ( | ) | const |
Returns the initialization status.
B_OK
, but SetInterval(), SetCount() and GetInfo() will all fail.B_OK
if the object was properly initialized or an error code otherwise.Sets the number of times message should be sent.
count | Specifies how many times the message shall be sent. A negative value indicates that the message will be sent forever, or until the BMessageRunner is reconfigured or deleted. |
B_OK
on success or an error code otherwise. B_OK | Everything went fine. |
B_NO_INIT | The message runner was not properly initialized. |
B_BAD_VALUE | interval was 0 or negative, or the message runner had already sent all messages and became unusable. |
Sets the interval of time between messages.
interval | The new interval in microseconds. |
B_OK
on success or an error code otherwise. B_OK | Everything went fine. |
B_NO_INIT | The message runner was not properly initialized. |
B_BAD_VALUE | interval was 0 or negative, or the message runner had already sent all messages and became unusable. |
|
static |
Creates and initializes a detached BMessageRunner and instructs the system roster to send the specified message to the target count times every interval microseconds, reply messages are sent to be_app_messenger
.
You cannot alter the runner after the creation, and it will be deleted automatically the last message is sent.
target | Target of the message(s). |
message | The message to be sent to the target. |
interval | Period of time before the first message is sent and between messages (if more than one shall be sent) in microseconds. |
count | Specifies how many times the message shall be sent. A negative value indicates that the message will be sent forever, or until the BMessageRunner is reconfigured or deleted. |
|
static |
Creates and initializes a detached BMessageRunner and instructs the system roster to send the specified message to the target count times every interval microseconds.
You cannot alter the runner after the creation, and it will be deleted automatically once the last message is sent.
target | Target of the message(s). |
message | The message to be sent to the target. |
interval | Period of time before the first message is sent and between messages (if more than one shall be sent) in microseconds. |
count | Specifies how many times the message shall be sent. A negative value indicates that the message will be sent forever, or until the BMessageRunner is reconfigured or deleted. |
replyTo | Target replies to the delivered message(s) shall be sent to. |