The implementation of the messaging system is fairly straightforward; the messaging queues can be held in the address entry struct in the addressing system. In addition to this, only few functions have to be implemented.
Despite of the simplicity of the messaging system, it is convenient to make a separate module, mainly to have a clean interface to the messaging functions.
The message queue is implemented as a linked list. The list is placed in the in the ActorEntry-struct of the agent that is kept in the hash table of the addressing addressing system (see [Addressing module implementation].)
All the the needed functions were described in [Messaging System Specification]. The interface is described below.
Description: | The callback called from the networking module, when a message arrives. |
Description: | Initialize the messaging system. Needs to be done first! |
Description: | Writes a message to file. Returns MESS_OK on success, MESS_FAILED if otherwise (bad fd etc.) |
Description: | Register a callback to be called when an external agent gets a message. |
Description: | Register a callback to be called when a special agent (for example, a kernel implementing agent) gets a message. The identifier should be currently between range 0..255 (inclusive). |
Description: | Send a heap heap to actor address. Returns MESS_OK on success, MESS_FAILED if otherwise. Notice, that in the most situations the message is quietly lost rather than notifying the caller with ADDR_FAILED, if it can't be delievered. ADDRESS is not freed by mess_sendheap. free(data_to_free) is called by mess_sendheap when the message has been sent. |
Description: | Re-enables sending messages to an Actor. Returns the number of addresses affected. |
Description: | Writes a message to file. Returns MESS_OK on success, MESS_FAILED if otherwise (bad fd etc.) |