5 #ifdef TGT_OS_TYPE_VXWORKS
9 #ifdef TGT_OS_TYPE_LINUX
10 #include <sys/types.h>
24 #define IPC_QUEUE_TIMEOUT_SEC (1)
36 (void) mq_close(this->
handle);
49 #ifndef TGT_OS_TYPE_VXWORKS
51 (void)snprintf(pid,
sizeof(pid),
".%d",getpid());
52 pid[
sizeof(pid)-1] = 0;
58 memset(&att,0,
sizeof(att));
59 att.mq_maxmsg = depth;
60 att.mq_msgsize = msgSize;
68 handle = mq_open(this->m_name.toChar(), O_RDWR | O_CREAT | O_EXCL, 0666, &att);
74 (void)mq_unlink(this->m_name.toChar());
80 handle = mq_open(this->m_name.toChar(), O_RDWR | O_CREAT | O_EXCL, 0666, &att);
88 QueueHandle* queueHandle =
new(std::nothrow) QueueHandle(handle);
89 if (
nullptr == queueHandle) {
92 this->
m_handle =
reinterpret_cast<POINTER_CAST
>(queueHandle);
101 QueueHandle* queueHandle =
reinterpret_cast<QueueHandle*
>(this->
m_handle);
102 if (
nullptr != queueHandle) {
105 this->
m_handle =
reinterpret_cast<POINTER_CAST
>(
nullptr);
106 (void) mq_unlink(this->m_name.toChar());
111 QueueHandle* queueHandle =
reinterpret_cast<QueueHandle*
>(this->
m_handle);
112 mqd_t handle = queueHandle->handle;
118 if (
nullptr == buffer) {
122 bool keepTrying =
true;
125 gettimeofday(&now,
nullptr);
126 struct timespec wait;
127 wait.tv_sec = now.tv_sec;
128 wait.tv_nsec = now.tv_usec * 1000;
133 NATIVE_INT_TYPE stat = mq_timedsend(handle,
reinterpret_cast<const char*
>(buffer), size, priority, &wait);
167 QueueHandle* queueHandle =
reinterpret_cast<QueueHandle*
>(this->
m_handle);
168 mqd_t handle = queueHandle->handle;
175 bool notFinished =
true;
176 while (notFinished) {
178 gettimeofday(&now,
nullptr);
179 struct timespec wait;
180 wait.tv_sec = now.tv_sec;
181 wait.tv_nsec = now.tv_usec * 1000;
186 size = mq_timedreceive(handle,
reinterpret_cast<char*
>(buffer),
static_cast<size_t>(capacity),
187 #ifdef TGT_OS_TYPE_VXWORKS
188 reinterpret_cast<int*
>(&priority), &wait);
190 reinterpret_cast<unsigned int*
>(&priority), &wait);
226 QueueHandle* queueHandle =
reinterpret_cast<QueueHandle*
>(this->
m_handle);
227 mqd_t handle = queueHandle->handle;
230 int status = mq_getattr(handle, &attr);
232 return static_cast<U32
>(attr.mq_curmsgs);
241 QueueHandle* queueHandle =
reinterpret_cast<QueueHandle*
>(this->
m_handle);
242 mqd_t handle = queueHandle->handle;
245 int status = mq_getattr(handle, &attr);
247 return static_cast<U32
>(attr.mq_maxmsg);
251 QueueHandle* queueHandle =
reinterpret_cast<QueueHandle*
>(this->
m_handle);
252 mqd_t handle = queueHandle->handle;
255 int status = mq_getattr(handle, &attr);
257 return static_cast<U32
>(attr.mq_msgsize);