Discussion:
callback with lanes
Victor Bombi
2014-06-22 09:41:29 UTC
Permalink
Hello,

I define a function to be called as a callback inside a luaLanes lane. I
send it to the main lua_state with a linda in order to use it as an argument
to a ffi C function. In this function I print the arguments it receives. The
C function is called several times in a loop. If io.read"*l" is used after
the C function call it prints: cdata<struct ReplyAddress *>: 0x023f2128
cdata<char *>: 0x0472de50 72 . But if io.read"*l" is removed then it
prints: function: builtin#18 function: builtin#18 function:
builtin#18 and luajit crashes. Just in case I have used jit.off() in the
main lua_state and in the lanes lua_state.

What is happening? What can be done?

Thanks
victor
Victor Bombi
2014-06-22 11:58:58 UTC
Permalink
I still dont understand what was happening but it seems that the way I send
the callback to another lane is important.

this cheats luaLanes to think that is is sending a number (I guess its a
pointer) instead of a function (Lanes tries to replicate in other lua_State)
Now I send with
cbbb = ffi.cast("ReplyFunc",ReplyFunS)
linda:send("func",tonumber(ffi.cast("int", cbbb)))
and receive with
local key, respfunc = linda:receive("func")
respfunc = ffi.cast("ReplyFunc",respfunc)

and seems to work. Any thougths?
thanks
victor

----- Original Message -----
From: "Victor Bombi" <sonoro-***@public.gmane.org>
To: <luajit-***@public.gmane.org>
Sent: Sunday, June 22, 2014 11:41 AM
Subject: callback with lanes
Post by Victor Bombi
Hello,
I define a function to be called as a callback inside a luaLanes lane. I
send it to the main lua_state with a linda in order to use it as an
argument to a ffi C function. In this function I print the arguments it
receives. The C function is called several times in a loop. If
io.read"*l" is used after the C function call it prints: cdata<struct
ReplyAddress *>: 0x023f2128 cdata<char *>: 0x0472de50 72 . But if
builtin#18 function: builtin#18 and luajit crashes. Just in case I have
used jit.off() in the main lua_state and in the lanes lua_state.
What is happening? What can be done?
Thanks
victor
Loading...