SimGrid
3.7
Scalable simulation of distributed systems
|
Defines | |
#define | gras_cb_register(msgtype_name, cb) |
Bind the given callback to the given message type (described by its name) | |
#define | gras_cb_unregister(msgtype_name, cb) |
Unbind the given callback to the given message type (described by its name) | |
Typedefs | |
typedef struct s_gras_msg_cb_ctx * | gras_msg_cb_ctx_t |
Context of callbacks (opaque structure, created by the middleware only, never by user) | |
typedef int(* | gras_msg_cb_t )(gras_msg_cb_ctx_t ctx, void *payload) |
Type of message callback functions. | |
Functions | |
xbt_socket_t | gras_msg_cb_ctx_from (gras_msg_cb_ctx_t ctx) |
Retrieve the expeditor of the message. | |
void | gras_cb_register_ (gras_msgtype_t msgtype, gras_msg_cb_t cb) |
Bind the given callback to the given message type. | |
void | gras_cb_unregister_ (gras_msgtype_t msgtype, gras_msg_cb_t cb) |
Unbind the given callback from the given message type. |
This is how to register a given function so that it gets called when a given type of message arrives.
You can register several callbacks to the same kind of messages, and they will get stacked. The lastly added callback gets the message first. If it consumes the message, it should return a true value when done. If not, it should return 0, and the message will be passed to the second callback of the stack, if any.
#define gras_cb_register | ( | msgtype_name, | |
cb | |||
) |
Bind the given callback to the given message type (described by its name)
Several callbacks can be attached to a given message type. The lastly added one will get the message first, and if it returns a non-null value, the message will be passed to the second one. And so on until one of the callbacks accepts the message.
Using gras_cb_register is a bit slower than using gras_cb_register_ since GRAS has to search for the given msgtype in the hash table, but you don't care in most case.
#define gras_cb_unregister | ( | msgtype_name, | |
cb | |||
) |
Unbind the given callback to the given message type (described by its name)
Using gras_cb_unregister is a bit slower than using gras_cb_unregister_ since GRAS has to search for the given msgtype in the hash table, but you don't care in most case.
typedef int(* gras_msg_cb_t)(gras_msg_cb_ctx_t ctx, void *payload) |
Type of message callback functions.
expeditor,: | a socket to contact who sent this message |
payload,: | the message itself |
Once a such a function is registered to handle messages of a given type with gras_cb_register(), it will be called each time such a message arrives (unless a gras_msg_wait() intercepts it on arrival).
If the callback accepts the message, it should free it after use.
void gras_cb_register_ | ( | gras_msgtype_t | msgtype, |
gras_msg_cb_t | cb | ||
) |
Bind the given callback to the given message type.
Several callbacks can be attached to a given message type. The lastly added one will get the message first, and if it returns a non-null value, the message will be passed to the second one. And so on until one of the callbacks accepts the message.
Back to the main Simgrid Documentation page |
The version of SimGrid documented here is v3.7. Documentation of other versions can be found in their respective archive files (directory doc/html). |
Generated by ![]() |