op_q_empty()

Abstract

Determines if the surrounding queue is completely empty of packets.

Syntax

op_q_empty ()
Argument Type Description
no arguments

Return Type

Boolean

Boolean value indicating whether the surrounding queue is empty.

This value is OPC_TRUE if the queue is empty, OPC_FALSE if the queue is not empty.

Example

/* determine if queue is empty; if not, then process its contents */
if (op_q_empty () == OPC_FALSE)
	{
	/* determine the number of subqueues */
	num_subqs = op_topo_child_count (op_id_self (), OPC_OBJTYPE_SUBQ);

	/* loop through each subqueue */
	for (i = 0; i < num_subqs; i++)
		{
		/* determine the number of packets in subqueue */
		num_pkts = op_subq_stat (i, OPC_QSTAT_PKSIZE);

		/* loop through each packet in subqueue */
		for (j = 0; j < num_pkts; j++)
			{
			/* schedule self interrupt based on packet’s insert time */
			pkptr = op_subq_pk_access (i, j);
			op_intrpt_schedule_self (op_q_insert_time (pkptr) + 0.05, PROC_COMP);
			}
		}
	}

Details

A queue is empty if none of its subqueues contain packets. A queue is initially empty, since all of its subqueues are empty. Packets are added to one or more subqueues within a queue via the KP op_subq_pk_insert(), and they are removed from subqueues via the KPs op_subq_pk_remove() and op_subq_flush(), or from the queue as a whole via the KP op_q_flush().

Q package KPs must only be invoked within the context of a process running on a queue module (or from a function which is directly or indirectly invoked by a queue process); invoking them from a process running on a processor, or from a pipeline stage model will cause an error.

Purpose

Provides a mechanism to determine if the surrounding queue is totally empty of packets. This KP is usually invoked as a conditional in a process model transition, or in the conditional clause of an if statement, to bracket a group of statements that should only be executed if the surrounding queue contains packets. Typically the bracketed statements will attempt to process one or more of the packets in the queue, removing them via the KP op_subq_pk_remove().

Errors

  • Program Abort: KP requires queue context.

Reference

  • Use the KP op_subq_empty() to determine if a particular subqueue is empty of packets
  • Use the KP op_subq_stat(), with the OPC_QSTAT_PKSIZE symbolic constant as an argument, to determine the number of packets contained in a subqueue
  • Use the KP op_subq_pk_remove() to remove a packet from a subqueue, and obtain a pointer to it
  • Use the KP op_q_flush() to remove all the packets from a queue
  • Use the KP op_subq_flush() to remove all the packets from a subqueue

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