5 #ifdef TGT_OS_TYPE_VXWORKS
9 #ifdef TGT_OS_TYPE_LINUX
10 #include <sys/types.h>
23 #define IPC_QUEUE_TIMEOUT_SEC (1)
35 (void) mq_close(this->
handle);
48 #ifndef TGT_OS_TYPE_VXWORKS
50 (void)snprintf(pid,
sizeof(pid),
".%d",getpid());
51 pid[
sizeof(pid)-1] = 0;
57 memset(&att,0,
sizeof(att));
58 att.mq_maxmsg = depth;
59 att.mq_msgsize = msgSize;
67 handle = mq_open(this->m_name.toChar(), O_RDWR | O_CREAT | O_EXCL, 0666, &att);
73 (void)mq_unlink(this->m_name.toChar());
79 handle = mq_open(this->m_name.toChar(), O_RDWR | O_CREAT | O_EXCL, 0666, &att);
87 QueueHandle* queueHandle =
new QueueHandle(handle);
88 if (
NULL == queueHandle) {
91 this->
m_handle = (POINTER_CAST) queueHandle;
100 QueueHandle* queueHandle = (QueueHandle*) this->
m_handle;
101 if (
NULL != queueHandle) {
105 (void) mq_unlink(this->m_name.toChar());
110 QueueHandle* queueHandle = (QueueHandle*) this->
m_handle;
111 mqd_t handle = queueHandle->handle;
117 if (
NULL == buffer) {
121 bool keepTrying =
true;
124 gettimeofday(&now,
NULL);
125 struct timespec wait;
126 wait.tv_sec = now.tv_sec;
127 wait.tv_nsec = now.tv_usec * 1000;
132 NATIVE_INT_TYPE stat = mq_timedsend(handle, (
const char*) buffer, size, priority, &wait);
166 QueueHandle* queueHandle = (QueueHandle*) this->
m_handle;
167 mqd_t handle = queueHandle->handle;
174 bool notFinished =
true;
175 while (notFinished) {
177 gettimeofday(&now,
NULL);
178 struct timespec wait;
179 wait.tv_sec = now.tv_sec;
180 wait.tv_nsec = now.tv_usec * 1000;
185 size = mq_timedreceive(handle, (
char*) buffer, (
size_t) capacity,
186 #ifdef TGT_OS_TYPE_VXWORKS
187 (
int*)&priority, &wait);
189 (
unsigned int*) &priority, &wait);
225 QueueHandle* queueHandle = (QueueHandle*) this->
m_handle;
226 mqd_t handle = queueHandle->handle;
229 int status = mq_getattr(handle, &attr);
231 return (U32) attr.mq_curmsgs;
240 QueueHandle* queueHandle = (QueueHandle*) this->
m_handle;
241 mqd_t handle = queueHandle->handle;
244 int status = mq_getattr(handle, &attr);
246 return (U32) attr.mq_maxmsg;
250 QueueHandle* queueHandle = (QueueHandle*) this->
m_handle;
251 mqd_t handle = queueHandle->handle;
254 int status = mq_getattr(handle, &attr);
256 return (U32) attr.mq_msgsize;