op_ev_equal()
Abstract
Compares two event handles for equality.
Syntax
op_ev_equal (evhandle_a, evhandle_b)
| Argument | Type | Description |
|---|---|---|
evhandle_a |
Evhandle |
event handle [An event handle can be obtained from several KPs in this package—such as op_ev_current(), op_ev_seek_time(), and op_ev_next()—and others such as op_intrpt_schedule_self().]. |
evhandle_b |
Evhandle |
event handle [An event handle can be obtained from several KPs in this package—such as op_ev_current(), op_ev_seek_time(), and op_ev_next()—and others such as op_intrpt_schedule_self().]. |
Return Type
Boolean
Boolean value indicating if two event handles refer to the same event.
OPC_TRUE is returned if the two event handles refer to the same event; OPC_FALSE is returned if they do not or if a recoverable error occurs.
Example
retrans_event = op_intrpt_schedule_self (time, 0)
...
/* if the current event is the retransmit timer, */
/* then retransmit the packet. */
cur_event = op_ev_current ();
if (op_ev_equal (cur_event, retrans_event) == OPC_TRUE)
{
op_pk_send (pkptr, 0);
}
Details
Two event handles are considered equal if both refer to the same event. Note that Evhandles are data-structures (as opposed to scalar variables or pointers) and that they should not be compared directly via the C language == (equals) operator.
This KP performs a test for Evhandle validity prior to returning a result, thus preventing its use for comparisons of event handles that refer to canceled or otherwise invalid events.
Purpose
Provides a mechanism to compare two Evhandles for equality. A typical application of this KP is to verify that the current event, for which an Evhandle can be obtained via op_ev_current(), is an event that is expected by comparing it to an Evhandle obtained earlier from a KP such as op_intrpt_schedule_self().
Errors
- Program Abort: Segmentation violation. (due to a malformed event handle)
- Recoverable Error: Event handle refers to an event that is either invalid or not currently scheduled.
Reference
- Use the KP op_ev_valid() to determine is an Evhandle is valid
- Use the KP op_ev_type() to determine the type of the event
- Use the KP op_ev_time() to determine the scheduled time of the event
- Use the KP op_ev_pending() to determine if the event is pending