op_ev_code()
Abstract
Obtains the numeric code associated with the specified event.
Syntax
op_ev_code (evhandle)
| Argument | Type | Description |
|---|---|---|
evhandle |
Evhandle |
event handle that identifies the event [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
int
Numeric code associated with the specified event. The constant OPC_EV_CODE_INVALID will be returned if a recoverable error occurs.
[This value is an integer with a user-defined interpretation supplied when remote, self, or multicast interrupts are requested. Typically, it identifies the purpose of the interrupt.]
Example
/* Obtain the currently executing event (it must be at this module, */
/* since this module woke up.) and the one after it. */
this_event = op_ev_current ();
next_event = op_ev_next_local (this_event);
/* Loop through all of the events scheduled for this module */
/* and cancel any that are retransmission timers. */
while (op_ev_valid (next_event))
{
if ((op_ev_type (next_event) == OPC_INTRPT_SELF) &&
(op_ev_code (next_event) == RETRANS_TIMER))
{
retrans_timer = next_event;
next_event = op_ev_next_local (retrans_timer);
op_ev_cancel (retrans_timer);
}
else
/* Obtain the next event; if there are no more events, op_ev_next_local () */
/* will return an invalid event handle and the loop will terminate. */
next_event = op_ev_next_local (next_event);
}
Details
This KP is only guaranteed to return valid results when applied to an event that has an associated code. The three types of interrupts that support codes are self, remote, and multicast interrupts.
Purpose
Provides a mechanism to determine the user-defined numeric code associated with an event, in order to identify its purpose. This is necessary when there are several different events of the same type pending for a process, but these interrupts are associated with different purposes. An example would be multiple time-out intervals delimited by self interrupts.
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 if the Evhandle is valid
- Use the KP op_ev_type() to determine the type of an event
- Use the KP op_ev_stat() to determine the input statistic index of a current statistic interrupt
- Use the KP op_ev_strm() to determine the stream index of a current stream interrupt
- Use the KP op_ev_time() to determine the scheduled time of an event
- Use the KP op_ev_ici() to obtain the ICI associated with an event