OMTimeout 类

超时是一个事件,它用于发出指定时间间隔已到期的通知(即,它实现 UML 时间事件)。

超时要么由通过超时过渡进入状态的实例创建,要么由来自用户代码的延迟请求创建。在后一种情况下,此事件的 timeoutDelayId 如下所示:
const short timeoutDelayId = -1;

OMTimeout 类是在头文件 event.h 中声明的。

OMTimeout 使用以下比较函数来处理其堆结构:
int operator==(OMTimeout& tn)
{OMBoolean matchDest = getDestination() ==
tn.getDestination();
OMBoolean matchId = ((getTimeoutId() ==
tn.getTimeoutId()) || (getTimeoutId() ==
OMEventAnyEventId) ||
(OMEventAnyEventId == tn.getTimeoutId()));
return (matchDest && matchId);
}
int operator>(OMTimeout& tn) {return dueTime >
tn.dueTime;}
int operator<(OMTimeout& tn) {return dueTime <
tn.dueTime;}

属性概要
timeoutDelayId - 标识来自用户代码的延迟请求
宏摘要
DECLARE_MEMORY_ALLOCATOR - 指定一组为超时声明内存池的方法
构造概要
OMTimeout
构造 OMTimeout 对象
~OMTimeout
销毁 OMTimeout 对象
方法概要
operator ==
确定 destinationTimeout 的当前值是否与指定超时的当前值相同
operator>
确定 Timeout 的当前值是否大于指定超时的到期时间
~OMCollection
确定 Timeout 的当前值是否小于指定超时的到期时间
删除
从堆中删除超时
getDelay
返回 delayTime 的当前值
getDueTime
返回存储在堆中的超时请求的到期时间
getTimeoutId
返回 timeoutId 的当前值
isNotDelay
确定超时事件是否是超时延迟
new
分配额外内存
setDelay
设置 Timeout 的值
setDueTime
指定 Timeout 属性的值
setRelativeDueTime
根据当前系统时间和请求的延迟时间来计算和设置超时的到期时间
setState
由框架用来设置当前状态
setTimeoutId
指定 timeoutId 的值
属性

timeoutDelayId

此全局属性用于标识来自用户代码的延迟请求。其定义如下所示:

const short timeoutDelayId = -1;

DECLARE_MEMORY_ALLOCATOR

此公共宏用于指定一组为超时声明内存池的方法。缺省超时数量为 100

DECLARE_MEMORY_ALLOCATOR 宏是在 MemAlloc.h 中定义的,如下所示:

#define DECLARE_MEMORY_ALLOCATOR (CLASSNAME)
   
   public:
   
   CLASSNAME * OMMemoryPoolNextChunk;
   DECLARE_ALLOCATION_OPERATORS
      static void OMMemoryPoolIsEmpty();
      static void OMMemoryPoolSetIncrement(int value);
      static void OMCallMemoryPoolIsEmpty(
         OMBoolean flagValue);
      static void OMSetMemoryAllocator(
         CLASSNAME*(*newAllocator)(int));

反馈