RMsgQueueBase Class Reference

#include <e32msgqueue.h>

class RMsgQueueBase : public RHandleBase

Inherits from

Detailed Description

Provides implementation for managing an asynchronous message queue, and is a base class for the RMsgQueue templated class.

See also: RMsgQueue

Member Enumeration Documentation

Enum anonymous

The limit for the size of an individual message.

EnumeratorValueDescription
KMaxLength256

Member Function Documentation

CancelDataAvailable ( )

IMPORT_C voidCancelDataAvailable()

Cancels an outstanding data available notification request.

If the request is not already complete, then it now completes with KErrCancel.

panic
KERN-EXEC 50 if attempting to cancel an outstanding request made by a thread in a different process.

See also: RMsgQueueBase::NotifyDataAvailable

CancelSpaceAvailable ( )

IMPORT_C voidCancelSpaceAvailable()

Cancels an outstanding space available notification request.

If the request is not already complete, then it now completes with KErrCancel.

panic
KERN-EXEC 50 if attempting to cancel an outstanding request made by a thread in a different process.

See also: RMsgQueueBase::NotifySpaceAvailable

CreateGlobal ( const TDesC &, TInt, TInt, TOwnerType )

IMPORT_C TIntCreateGlobal(const TDesC &aName,
TIntaSize,
TIntaMsgLength,
TOwnerTypeaType = EOwnerProcess
)

Creates a global message queue, and opens a handle to that message queue.

The kernel side object representing the message queue is given the name contained in the specified descriptor, which makes it global, i.e. it is visible to all processes. This means that any thread in any process can search for the message queue, and open a handle to it. If the specified name is empty the kernel side object representing the message queue is unnamed and so cannot be opened by name or searched for. It can however be passed to another process as a process parameter or via IPC.

By default, any thread in the process can use this handle to access the message queue. However, specifying EOwnerThread as the fourth parameter to this function, means that only the creating thread can use this handle to access the message queue; any other thread in this process that wants to access the message queue must either duplicate this handle or use OpenGlobal().

panic
KERN-EXEC 49 if aSize is less than or equal to zero.
panic
KERN-EXEC 48 if aMsgLength is not a multiple of 4 bytes, is less than 4, or is greater than KMaxLength.

See also: KMaxLength RMsgQueueBase::OpenGlobal

ParameterDescription
aNameThe name to be assigned to the message queue
aSizeThe number of message 'slots' in the queue. This must be a positive value, i.e. greater than zero.
aMsgLengthThe size of each message for the queue, this cannot exceed KMaxLength.
aTypeThe type of handle to be created. EOwnerProcess is the default value, if not explicitly specified.

Returns: KErrNone if the queue is created sucessfully, otherwise one of the other system wide error codes.

CreateLocal ( TInt, TInt, TOwnerType )

IMPORT_C TIntCreateLocal(TIntaSize,
TIntaMsgLength,
TOwnerTypeaType = EOwnerProcess
)

Creates a message queue that is private to the current process, and opens a handle to that message queue.

The Kernel side object representing the message queue is unnamed. This means that it is not possible to search for the message queue, and this makes it local to the current process.

By default, any thread in the process can use this handle to access the message queue. However, specifying EOwnerThread as the third parameter to this function means that only the creating thread can use the handle to access the message queue; any other thread in this process that wants to access the message queue must duplicate this handle.

panic
KERN-EXEC 49 if aSize is less than or equal to zero.
panic
KERN-EXEC 48 if aMsgLength is not a multiple of 4 bytes, is less than 4, or is greater than KMaxLength.

See also: KMaxLength

ParameterDescription
aSizeThe number of message 'slots' in the queue. This must be a positive value, i.e. greater than zero.
aMsgLengthThe size of each message for the queue, this cannot exceed KMaxLength.
aTypeThe type of handle to be created. EOwnerProcess is the default value, if not explicitly specified.

Returns: KErrNone if the queue is created sucessfully, otherwise one of the other system wide error codes.

MessageSize ( )

IMPORT_C TIntMessageSize()

Gets the size of message slots in the queue.

Returns: The size of a message slot in the queue.

NotifyDataAvailable ( TRequestStatus & )

IMPORT_C voidNotifyDataAvailable(TRequestStatus &aStatus)

Requests notification when there is at least one message in the queue.

A thread can have only one data available notification request outstanding on this message queue. If a second request is made before the first request completes, then the calling thread is panicked.

panic
KERN-EXEC 47 if a second request is made while the first request remains outstanding.
ParameterDescription
aStatusThe request status object to be completed when a message becomes available.

NotifySpaceAvailable ( TRequestStatus & )

IMPORT_C voidNotifySpaceAvailable(TRequestStatus &aStatus)

Requests notification when space becomes available in the queue.

This is an asynchronous request that completes when there is at least one 'slot'available in the queue.

A thread can have only one space available notification request outstanding on this message queue. If a second request is made before the first request completes, then the calling thread is panicked.

panic
KERN-EXEC 47 if a second request is made while the first request remains outstanding.
ParameterDescription
aStatusThe request status object to be completed when space becomes available.

Open ( RMessagePtr2, TInt, TOwnerType )

IMPORT_C TIntOpen(RMessagePtr2aMessage,
TIntaParam,
TOwnerTypeaType = EOwnerProcess
)

Opens a global message queue using a handle passed in a server message.

By default, any thread in the process can use this handle to access the message queue. However, specifying EOwnerThread as the third parameter to this function, means that only the opening thread can use this handle to access the message queue.

ParameterDescription
aMessageThe server message.
aParamThe number of the message parameter which holds the handle.
aTypeThe type of handle to be created. EOwnerProcess is the default value, if not explicitly specified.

Open ( TInt, TOwnerType )

IMPORT_C TIntOpen(TIntaArgumentIndex,
TOwnerTypeaType = EOwnerProcess
)

Opens a message queue using the handle passed in during process creation.

ParameterDescription
aArgumentIndexThe number on the parameter which holds the handle.
aTypeThe type of handle to be created. EOwnerProcess is the default value, if not explicitly specified.

Returns: KErrNone, ifsuccessful; KErrArgument, if aArgumentIndex doesn't contain a message queue handle; KErrNotFound, if aArgumentIndex is empty.

OpenGlobal ( const TDesC &, TOwnerType )

IMPORT_C TIntOpenGlobal(const TDesC &aName,
TOwnerTypeaType = EOwnerProcess
)

Opens a global message queue.

Global message queues are identified by name.

By default, any thread in the process can use this handle to access the message queue. However, specifying EOwnerThread as the second parameter to this function, means that only the opening thread can use this handle to access the message queue; any other thread in this process that wants to access the message queue must either duplicate this handle or use OpenGlobal() again.

See also: RMsgQueueBase::OpenGlobal

ParameterDescription
aNameThe name of the message queue.
aTypeThe type of handle to be created. EOwnerProcess is the default value, if not explicitly specified.

Returns: KErrNone if queue opened sucessfully, otherwise one of the other system wide error codes.

Receive ( TAny *, TInt )

IMPORT_C TIntReceive(TAny *aPtr,
TIntaLength
)

Retrieves the first message in the queue.

The function does not wait (i.e. block), if the queue is empty.

panic
KERN-EXEC 48 if aLength is not equal to the message length specified when the queue was created.
ParameterDescription
aPtrA pointer to a buffer to receive the message data.
aLengthThe length of the buffer for the message, this must match the queue's message size.

Returns: KErrNone, ifsuccessful; KErrUnderflow, if the queue is empty.

ReceiveBlocking ( TAny *, TInt )

IMPORT_C voidReceiveBlocking(TAny *aPtr,
TIntaLength
)

Retrieves the first message in the queue, and waits if the queue is empty.

The function uses NotifyDataAvailable() to provide the blocking operation. Note it is not possible to cancel a call to ReceiveBlocking().

panic
KERN-EXEC 48 if aLength is not equal to the message length specified when the queue was created.

See also: RMsgQueueBase::NotifyDataAvailable

ParameterDescription
aPtrA pointer to a buffer to receive the message data.
aLengthThe length of the buffer for the message, this must match the queue's message size.

Send ( const TAny *, TInt )

IMPORT_C TIntSend(const TAny *aPtr,
TIntaLength
)

Sends a message through this queue.

The function does not wait (i.e. block), if the queue is full.

Note that, once on the queue, the content of the message cannot be accessed other than through a call to Receive() or ReceiveBlocking().

panic
KERN-EXEC 48 if aLength is greater than the message length specified when the queue was created, or if aLength is less than or equal to zero.

See also: RMsgQueueBase::Receive RMsgQueueBase::ReceiveBlocking

ParameterDescription
aPtrA pointer to the message data
aLengthThe length of the message data, this must not exceed the queue's message size.

Returns: KErrNone, if successful; KErrOverflow, if queue is full,

SendBlocking ( const TAny *, TInt )

IMPORT_C voidSendBlocking(const TAny *aPtr,
TIntaLength
)

Sends a message through this queue, and waits for space to become available if the queue is full.

The function uses NotifySpaceAvailable() to provide the blocking operation. Note that it is not possible to cancel a call to SendBlocking().

panic
KERN-EXEC 48 if aLength is greater than the message length specified when the queue was created, or if aLength is less than or equal to zero.

See also: RMsgQueueBase::NotifySpaceAvailable

ParameterDescription
aPtrA pointer to the message data.
aLengthThe length of the message data, this must not exceed the queue's message size.