* \param src_process the sender
* \param dst_process the receiver
*/
-static void task_copy_callback(m_task_t task, m_process_t src_process,
- m_process_t dst_process) {
+static void task_copy_callback(m_task_t task, msg_process_t src_process,
+ msg_process_t dst_process) {
lua_State* src = MSG_process_get_data(src_process);
lua_State* dst = MSG_process_get_data(dst_process);
sglua_copy_value(src, dst);
/* src: ... task
dst: ... task */
- sglua_task_register(dst); /* dst: ... */
+ sglua_task_register(dst);
+ /* dst: ... */
/* the receiver is now the owner of the task and may destroy it:
* make the sender forget the C task so that it doesn't garbage */
* - Argument 1 (task): the task to send
* - Argument 2 (string or compatible): mailbox name, as a real string or any
* type convertible to string (numbers always are)
+ * - Argument 3 (number, optional): timeout (default is no timeout)
* - Return values (boolean + string): true if the communication was successful,
* or false plus an error string in case of failure, which may be "timeout",
* "host failure" or "transfer failure"
{
m_task_t task = sglua_check_task(L, 1);
const char* mailbox = luaL_checkstring(L, 2);
- /* task mailbox ... */
+ double timeout;
+ if (lua_gettop(L) >= 3) {
+ timeout = luaL_checknumber(L, 3);
+ }
+ else {
+ timeout = -1;
+ /* no timeout by default */
+ }
lua_settop(L, 1);
/* task */
sglua_task_register(L);
/* -- */
- MSG_error_t res = MSG_task_send(task, mailbox);
+ MSG_error_t res = MSG_task_send_with_timeout(task, mailbox, timeout);
if (res == MSG_OK) {
lua_pushboolean(L, 1);
{
m_task_t task = NULL;
const char* mailbox = luaL_checkstring(L, 1);
- int timeout;
+ double timeout;
if (lua_gettop(L) >= 2) {
/* mailbox timeout ... */
timeout = luaL_checknumber(L, 2);