逾時是用於通知指定時間間隔過期的事件(即它會實作 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;}
此公用巨集指定指定一組方法,來宣告逾時的記憶體儲存區。 預設逾時數目是 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));