op_strm_max_index_in()

摘要

获取连接到外围处理器或队列的任意输入流的最大索引。

语法

op_strm_max_index_in ()
参数 类型 说明
无参数

返回类型

int

任意已连接输入流的最大索引。由于输入流编号从零开始,若模块没有已连接的输入流,将返回 -1。

示例

/** loop through all input streams, generating an access interrupt for each **/

/* determine the number of allocated input streams */
alloc_instrms = op_strm_max_index_in ();

/* loop through each allocated stream */
for (i = 0; i <= alloc_instrms; i++)
	{
	/* if an input stream is connected, and... */
	if (op_strm_connected (OPC_STRM_IN, i) == OPC_TRUE)
		{
		/* if an input stream is connected, access a packet from the source module. */
		op_strm_access (i);

		/* Collect and forward the packet onto the bus, if one was obtained. */
		if (op_strm_empty (i) == OPC_FALSE)
			op_pk_send (op_pk_get (i), OUTSTRM_BUS);
		}
	}

详情

本内核过程返回的值是所有已连接输入流的最高物理索引(即数据包流对象的 dest stream 属性的最大值)。若输入流是稀疏连接的,则返回值与已连接输入流的数量不一定相关。反之,若所有已连接的输入流是连续的,则返回值等于已连接流的数量减一,因为编号从零开始。但无论如何,最大索引(本内核过程返回)加一总是已连接输入流数量的一个上界。

用途

提供一种为连接到其他对象的输入流数量设定上界的机制。当需要对所有已连接输入流执行某项操作、而过程又不具备关于哪些流已连接的内置知识时,这一点很有用。此时,过程可以测试直到并包括本内核过程返回的最大索引的所有输入流,并通过调用内核过程 op_strm_connected() 判定它们是否已连接。

错误

  • 程序中止:内核过程需要过程上下文。

参考

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · 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