op_ev_pending()
摘要
判断该事件是否已被计划在未来执行。
语法
op_ev_pending (evhandle)
| 参数 | 类型 | 说明 |
|---|---|---|
evhandle |
Evhandle |
标识该事件的事件句柄 [事件句柄可以从本包中的多个内核过程获取,例如 op_ev_current()、op_ev_seek_time() 和 op_ev_next(),以及 op_intrpt_schedule_self() 等其他内核过程。] |
返回类型
Boolean
如果事件等待执行则返回 OPC_TRUE;如果发生错误,或指定事件已经开始或已经完成执行(这隐含包括所有强制事件),则返回 OPC_FALSE。
示例
/* Find the first event that is in the event list. */
/* (i.e., not a current or forced event) */
this_event = op_ev_current ();
while (!op_ev_pending (next_event))
next_event = op_ev_next ();
/* Count the remote interrupts this module scheduled. */
ri_count = 0;
while (op_ev_valid (next_event))
{
if ((op_ev_type (next_event) == OPC_INTRPT_REMOTE) &&
(op_ev_src_id (next_event) == my_id))
{
ri_count++;
}
next_event = op_ev_next (next_event);
}
详情
如果事件位于事件列表中且尚未开始,则该事件处于等待(pending)状态。已经发生的事件、当前事件以及强制事件都不是等待状态。
用途
提供了一种判断事件是否已经发生的机制。通常这样做是为了确定事件是否可以被取消,因为只有等待状态的事件才允许被取消。
**注意:**该内核过程仅在顺序仿真上下文中有效。在并行仿真中,当前时间单元中的事件可能根据各线程的行为以不同的方式执行,此时它将表现为当前事件之后没有任何事件。
错误
- 程序中止:段错误。(由于格式错误的事件句柄)
参考
- 使用内核过程 op_ev_valid() 判断 Evhandle 是否有效
- 使用内核过程 op_ev_type() 获取事件的类型
- 使用内核过程 op_ev_time() 获取事件的计划时间