超时是一个事件,它用于发出指定时间间隔已到期的通知(即,它实现 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
此全局属性用于标识来自用户代码的延迟请求。其定义如下所示:
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));