#include <MessageQueue.h>
Inheritance diagram for OS::MessageQueue:
Public Member Functions | |
MessageQueue (int queueKey, bool exclusive) | |
Initializes the queue. | |
virtual long | bufferSize (void) |
virtual long | priority (void) |
virtual void | priority (long level) |
virtual void | close (void) |
Close the message queue. | |
virtual int | key (void) |
Get the message creation key Get the hash key used to create this queue. | |
virtual int | readInto (ByteArray *buffer, long startIndex, long count) |
virtual int | writeFrom (ByteArray *buffer, long startIndex, long count) |
virtual void | seekTo (long position) |
virtual bool | isActive (void) |
Answer the status of the queue. | |
Static Public Member Functions | |
static MessageQueue * | open (void) |
static MessageQueue * | open (String *key, bool exclusive=false) |
static MessageQueue * | open (bool exclusive) |
Protected Attributes | |
int | queueid |
The system-wide ID of the message queue. | |
int | queueCreationKey |
The key this queue has been created with. | |
bool | active |
Status of the message queue accessor. | |
int | _priority |
Message priority level. |
A message queue is part of the UNIX interprocess communication.
Definition at line 37 of file MessageQueue.h.
|
Initializes the queue.
Creates a new message queue with the given key. When
Definition at line 42 of file MessageQueue.cc. References _priority, active, queueCreationKey, and queueid. Referenced by open(). 00043 { 00044 int flags = 0664 | IPC_CREAT; 00045 00046 if (exclusive) 00047 flags = flags | IPC_EXCL; 00048 queueid = msgget(queueKey, flags); 00049 queueCreationKey = queueKey; 00050 if (queueid >= 0) active = true; 00051 _priority = 1; 00052 }
|
|
Reimplemented from Core::IOAccessor. Definition at line 70 of file MessageQueue.cc. References MAXBUFFERLEN. 00071 { 00072 return MAXBUFFERLEN; 00073 }
|
|
Close the message queue. Deallocates the message queue resource. It must be called to physically free the message queue from the system kernel IPC tables. Reimplemented from Core::IOAccessor. Definition at line 86 of file MessageQueue.cc. References active, and queueid.
|
|
Answer the status of the queue.
Definition at line 92 of file MessageQueue.h. References active. 00093 { return active; }
|
|
Get the message creation key Get the hash key used to create this queue.
Definition at line 80 of file MessageQueue.h. References queueCreationKey. 00081 { return queueCreationKey; }
|
|
Definition at line 59 of file MessageQueue.cc. References open(). 00060 { 00061 return MessageQueue::open(new String("stlib-MessageQueue"), exclusive); 00062 }
|
|
Definition at line 64 of file MessageQueue.cc. References Core::String::asCString(), getkey(), and MessageQueue(). 00065 { 00066 return new MessageQueue(getkey(key->asCString()), exclusive); 00067 }
|
|
Definition at line 54 of file MessageQueue.cc. Referenced by open(). 00055 { 00056 return MessageQueue::open(new String("stlib-MessageQueue")); 00057 }
|
|
Definition at line 75 of file MessageQueue.cc. References _priority. 00076 { 00077 _priority = level; 00078 }
|
|
Definition at line 80 of file MessageQueue.cc. References _priority. 00081 { 00082 return _priority; 00083 }
|
|
Reimplemented from Core::IOAccessor. Definition at line 94 of file MessageQueue.cc. References MAXBUFFERLEN, queueid, and Core::ByteArray::replace(). 00095 { 00096 int bytes; 00097 struct msgbuf { 00098 long mtype; 00099 unsigned char data[MAXBUFFERLEN]; 00100 } buf; 00101 00102 if (queueid < 0) return 0; 00103 if (count > MAXBUFFERLEN) count = MAXBUFFERLEN; 00104 00105 bytes = msgrcv(queueid, &buf, count, 0, MSG_NOERROR); 00106 if (bytes > 0) 00107 buffer->replace(startIndex, startIndex+bytes, buf.data); 00108 return bytes; 00109 }
|
|
Reimplemented from Core::IOAccessor. Definition at line 133 of file MessageQueue.cc. References Core::Object::shouldNotImplement(). 00134 { 00135 shouldNotImplement(new String(__PRETTY_FUNCTION__)); 00136 }
|
|
Reimplemented from Core::IOAccessor. Definition at line 111 of file MessageQueue.cc. References _priority, Core::Object::error(), MAXBUFFERLEN, queueid, and Core::ByteArray::rawBytesReadOnly(). 00112 { 00113 struct msgbuf { 00114 long mtype; 00115 unsigned char mtext[MAXBUFFERLEN]; 00116 } buf; 00117 00118 if (queueid < 0 || count < 1) 00119 return 0; 00120 00121 if (count > MAXBUFFERLEN) count = MAXBUFFERLEN; 00122 buf.mtype = _priority; 00123 /* Must memcpy, pointer doesn't work. */ 00124 memcpy(buf.mtext, &(buffer->rawBytesReadOnly())[startIndex], count); 00125 int error = msgsnd(queueid, &buf, count, 0); 00126 if (error < 0) 00127 perror(__PRETTY_FUNCTION__); 00128 00129 return (error < 0) ? 0 : count; 00130 }
|
|
Message priority level.
Definition at line 47 of file MessageQueue.h. Referenced by MessageQueue(), priority(), and writeFrom(). |
|
Status of the message queue accessor.
Definition at line 45 of file MessageQueue.h. Referenced by close(), isActive(), and MessageQueue(). |
|
The key this queue has been created with.
Definition at line 43 of file MessageQueue.h. Referenced by key(), and MessageQueue(). |
|
The system-wide ID of the message queue.
Definition at line 41 of file MessageQueue.h. Referenced by close(), MessageQueue(), readInto(), and writeFrom(). |