Module for inter-process communication (IPC) and message passing through
POSIX message queues. Has to be linked with -lrt
.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public, | parameter | :: | MQUEUE_MODE | = | int(o'0644') |
Default permissions (octal). |
integer, | public, | parameter | :: | MQUEUE_NAME_LEN | = | ID_LEN+1 |
Maximum message queue identifier length. |
integer, | public, | parameter | :: | MQUEUE_MAX_MSG | = | 10 |
Maximum number of messages in queue. |
integer, | public, | parameter | :: | MQUEUE_RDONLY | = | 0 |
Read-only access. |
integer, | public, | parameter | :: | MQUEUE_WRONLY | = | 1 |
Write-only access. |
integer, | public, | parameter | :: | MQUEUE_RDWR | = | 2 |
Read/write access. |
Generic message queue open function.
Opens POSIX message queue of given name.
The function returns the following error codes:
E_INVALID
if name is empty or starts with /
.E_MQUEUE
if system call to open the queue failed.Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mqueue_type), | intent(out) | :: | mqueue |
Message queue type. |
||
character(len=*), | intent(in) | :: | name |
Message queue name (without leading |
||
integer, | intent(in) | :: | max_msg |
Maximum number of messages in queue. |
||
integer, | intent(in) | :: | msg_size |
Message size. |
||
integer, | intent(in), | optional | :: | access |
Access type ( |
|
integer, | intent(in), | optional | :: | mode |
Access permissions. |
|
logical, | intent(in), | optional | :: | create |
Creates message queue if true. |
|
logical, | intent(in), | optional | :: | exclusive |
Opens message queue exclusively if true. |
|
logical, | intent(in), | optional | :: | blocking |
Blocking access if true. |
Opens message queue for reading/writing logs or observations (in blocking mode by default).
The function returns the following error codes:
E_INVALID
if type is invalid, name is empty, or name starts with /
.E_MQUEUE
if system call to open the queue failed.Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mqueue_type), | intent(out) | :: | mqueue |
Message queue type. |
||
integer, | intent(in) | :: | type |
Data type ( |
||
character(len=*), | intent(in) | :: | name |
Message queue name (without leading |
||
integer, | intent(in) | :: | access |
|
||
logical, | intent(in), | optional | :: | blocking |
Blocking access if true. |
Generic message queue read function.
Receives log from message queue. The received message shall not be
larger than parameter LOG_SIZE
. Returns E_MQUEUE
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mqueue_type), | intent(inout) | :: | mqueue |
Message queue type. |
||
type(log_type), | intent(out) | :: | log |
Log type. |
||
integer(kind=i8), | intent(in), | optional | :: | timeout |
Timeout in seconds. |
Receives observation from message queue. The received message shall
not be larger than parameter OBSERV_SIZE
. Returns E_MQUEUE
on
error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mqueue_type), | intent(inout) | :: | mqueue |
Message queue type. |
||
type(observ_type), | intent(out) | :: | observ |
Observation type. |
||
integer(kind=i8), | intent(in), | optional | :: | timeout |
Timeout in seconds. |
Receives message from message queue and returns data in buffer
.
The buffer size must equal the message size. Returns E_MQUEUE
on
error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mqueue_type), | intent(inout) | :: | mqueue |
Message queue type. |
||
character(len=*), | intent(inout) | :: | buffer |
Byte buffer. |
||
integer, | intent(out), | optional | :: | priority |
Message priority. |
|
integer(kind=i8), | intent(in), | optional | :: | timeout |
Timeout in seconds. |
Generic message queue write function.
Sends log message to message queue. Returns E_MQUEUE
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mqueue_type), | intent(inout) | :: | mqueue |
Message queue type. |
||
type(log_type), | intent(inout) | :: | log |
Log type. |
Sends observation to message queue. Returns E_MQUEUE
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mqueue_type), | intent(inout) | :: | mqueue |
Message queue type. |
||
type(observ_type), | intent(inout) | :: | observ |
Observation type. |
Sends log to message queue. Returns E_MQUEUE
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mqueue_type), | intent(inout) | :: | mqueue |
Message queue type. |
||
character(len=*), | intent(inout) | :: | buffer |
Byte buffer |
||
integer, | intent(in), | optional | :: | priority |
Priority |
Opaque POSIX message queue type.
Returns message queue attributes.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mqueue_type), | intent(inout) | :: | mqueue |
Message queue type. |
||
integer(kind=i8), | intent(out), | optional | :: | flags |
Flags. |
|
integer(kind=i8), | intent(out), | optional | :: | max_msg |
Maximum number of messages in queue. |
|
integer(kind=i8), | intent(out), | optional | :: | msg_size |
Message size. |
|
integer(kind=i8), | intent(out), | optional | :: | cur_msgs |
Current number of messages in queue. |
Closes message queue.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mqueue_type), | intent(inout) | :: | mqueue |
Message queue type. |
Deletes POSIX message queue.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mqueue_type), | intent(inout) | :: | mqueue |
Message queue type. |