OMThread (int wrapThread); OMThread(const char* const name = NULL, const long priority = OMOSThread::DefaultThreadPriority, const long stackSize = OMOSThread::DefaultStackSize, const long messageQueueSize = OMOSThread::DefaultMessageQueueSize, OMBoolean dynamicMessageQueue = TRUE);
wrapThread
指定是构造新的操作系统线程(这是缺省值,此时 wrapThread = 0),还是将新线程构造为当前线程中的包装器。
可能会使用包装器线程, 例如,在 Rational® Rhapsody® 创建自己的线程以附加到现有 GUI 线程的 GUI 应用程序中。
name
priority
DefaultThreadPriority 是在
os.h 中定义的,如下所示:
static const long DefaultThreadPriority;
缺省值在 xxos.cpp 中指定。例如,ntos.cpp 指定以下值:
const
long OMOSThread::DefaultThreadPriority =
THREAD_PRIORITY_NORMAL;
stackSize
DefaultStackSize 是在 os.h 中定义的,如下所示:
static const long DefaultStackSize;
缺省值在 xxos.cpp 中指定。例如,ntos.cpp 指定以下值:
const
long OMOSThread::DefaultStackSize = 0;
messageQueueSize
DefaultMessageQueueSize 是在
os.h 中定义的,如下所示:
static const
long DefaultMessageQueueSize;
缺省值在 xxos.cpp 中指定。例如,ntos.cpp 指定以下值:
const long OMOSThread::DefaultMessageQueueSize
=
100;
dynamicMessageQueue
消息队列是 OMThread 的重要构建块。它用于在 Rational Rhapsody 任务(活动类)之间进行任务间通信。OMOSThread 为多个写程序和一个读取器提供了线程安全的不受限消息队列 (FIFO)。此读取器将暂挂消息队列,直到有要处理的消息为止。