Symbian进程间通信 消息队列
2010-07-21 04:17:00 来源:WEB开发网Contents
* 1 Introduction
* 2 Usage of Message Queue
* 3 Creating a Queue
* 4 Sending data to the Queue
* 5 Receiving Messages from the Queue
* 6 Other Queue Properties
Introduction
Message Queues are one of the better and comfortable ways to send/receive messages/data between threads within a process(or a separate process).You can see other ways at Inter-Process Data Transfer and Inter-Thread Communication.
A queue is generally created to handle messages of a given type of defined(fixed) length. The size of a queue, ie, maximum number of messages, or slots, it can contain is defined and fixed when the queue is created. The size of message for which a queue is created, and the size of the queue is arbitrary, being limited only by system resources.
A Message Queue can be :
--A global queue, which is visible to all processes
--A local queue, which is local to the current process and not visible to any other process
Usage of Message Queue
The member functions defined in RMsgQueue are:
CreateGlobal(), CreateLocal(), Receive(), ReceiveBlocking(), Send(), SendBlocking()
Following are the neccessary steps to make use of a message queue:
* Create a queue
* Send data to the queue
* Receive message from the queue
* Other queue properites
Creating a Queue
RMsgQueue is the handle to a message queue.
class RMsgQueue : public RMsgQueueBase;
Here, RMsgQueueBase provides implementation for managing an asynchronous message queue, and is a base class for the RMsgQueue templated class.
class TMsgClass
{
public:
TInt iTemp1;
TInt iTemp2;
}
The following code shows how to create a global message queue with message
更多精彩
赞助商链接