op_ev_next_local()

摘要

获取指向下一个本地事件的事件句柄,即预期将在当前执行模块发生的下一个事件(仅适用于顺序仿真)。

语法

op_ev_next_local (evhandle)
参数 类型 说明
evhandle Evhandle 标识该事件的事件句柄
[事件句柄可以从本包中的多个内核过程获取,例如 op_ev_current()、op_ev_seek_time() 和 op_ev_next(),以及 op_intrpt_schedule_self() 等其他内核过程。]

返回类型

Evhandle

表示预期将在当前执行模块发生的下一个事件的事件句柄。如果发生可恢复错误,则返回无效的事件句柄。

示例

/* 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);
	}

详情

该内核过程返回指向将在调用该内核过程的处理器或队列处发生的下一个事件的事件句柄。因此,传递给该内核过程的事件句柄本身必须指向当前执行的处理器或队列的事件,否则会发生错误。

关于指定事件为强制事件时的行为,更多信息见内核过程 op_ev_next() 的 Details 小节。在所有情况下,该内核过程的行为与 op_ev_next() 完全相同,只是它会忽略非本地事件。

用途

提供了一种按顺序逐个遍历未来本地事件的机制。

**注意:**该内核过程仅在顺序仿真上下文中有效。在并行仿真中,当前时间单元中的事件可能根据各线程的行为以不同的方式执行,此时它将表现为当前事件之后没有任何事件。

错误

  • 程序中止:内核过程需要进程上下文。
  • 程序中止:段错误。(由于格式错误的事件句柄)
  • 可恢复错误:事件句柄指向的事件无效或当前未被计划。
  • 可恢复错误:事件句柄指向的事件不是本地事件。

参考

  • 使用内核过程 op_ev_current() 获取当前事件的 Evhandle
  • 使用内核过程 op_ev_next() 获取后续事件的事件句柄(Evhandle)

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com