4 #ifdef TGT_OS_TYPE_VXWORKS
8 #ifdef TGT_OS_TYPE_LINUX
32 ret = pthread_mutex_init(&this->
mp,
NULL);
39 (void) mq_close(this->
handle);
42 (void) pthread_mutex_destroy(&this->
mp);
58 #ifndef TGT_OS_TYPE_VXWORKS
60 (void)snprintf(pid,
sizeof(pid),
".%d",getpid());
61 pid[
sizeof(pid)-1] = 0;
67 memset(&att,0,
sizeof(att));
68 att.mq_maxmsg = depth;
69 att.mq_msgsize = msgSize;
73 handle = mq_open(this->m_name.toChar(), O_RDWR | O_CREAT | O_EXCL | O_NONBLOCK, 0666, &att);
79 (void)mq_unlink(this->m_name.toChar());
85 handle = mq_open(this->m_name.toChar(), O_RDWR | O_CREAT | O_EXCL, 0666, &att);
93 QueueHandle* queueHandle =
new QueueHandle(handle);
94 if (
NULL == queueHandle) {
97 this->
m_handle = (POINTER_CAST) queueHandle;
105 QueueHandle* queueHandle = (QueueHandle*) this->
m_handle;
107 (void) mq_unlink(this->m_name.toChar());
112 QueueHandle* queueHandle = (QueueHandle*) this->
m_handle;
113 mqd_t handle = queueHandle->handle;
114 pthread_cond_t* queueNotEmpty = &queueHandle->queueNotEmpty;
115 pthread_cond_t* queueNotFull = &queueHandle->queueNotFull;
116 pthread_mutex_t* mp = &queueHandle->mp;
122 if (
NULL == buffer) {
126 bool keepTrying =
true;
129 NATIVE_INT_TYPE stat = mq_send(handle, (
const char*) buffer, size, priority);
147 ret = pthread_mutex_lock(mp);
149 ret = pthread_cond_wait(queueNotFull, mp);
151 ret = pthread_mutex_unlock(mp);
161 ret = pthread_cond_signal(queueNotEmpty);
171 QueueHandle* queueHandle = (QueueHandle*) this->
m_handle;
172 mqd_t handle = queueHandle->handle;
173 pthread_cond_t* queueNotEmpty = &queueHandle->queueNotEmpty;
174 pthread_cond_t* queueNotFull = &queueHandle->queueNotFull;
175 pthread_mutex_t* mp = &queueHandle->mp;
183 bool notFinished =
true;
184 while (notFinished) {
185 size = mq_receive(handle, (
char*) buffer, (
size_t) capacity,
186 #ifdef TGT_OS_TYPE_VXWORKS
189 (
unsigned int*) &priority);
207 ret = pthread_mutex_lock(mp);
209 ret = pthread_cond_wait(queueNotEmpty, mp);
211 ret = pthread_mutex_unlock(mp);
223 ret = pthread_cond_signal(queueNotFull);
233 QueueHandle* queueHandle = (QueueHandle*) this->
m_handle;
234 mqd_t handle = queueHandle->handle;
237 int status = mq_getattr(handle, &attr);
239 return (U32) attr.mq_curmsgs;
248 QueueHandle* queueHandle = (QueueHandle*) this->
m_handle;
249 mqd_t handle = queueHandle->handle;
252 int status = mq_getattr(handle, &attr);
254 return (U32) attr.mq_maxmsg;
258 QueueHandle* queueHandle = (QueueHandle*) this->
m_handle;
259 mqd_t handle = queueHandle->handle;
262 int status = mq_getattr(handle, &attr);
264 return (U32) attr.mq_msgsize;