But in my thread which is listen on com1´´, rb_block_given_p says that no block is given. How to redirect´´ the block in the init function?
Well I’ve not understood : do you want to do something like this ?
[…]
Not really…
In Ruby I call
rv.rPAInit { |a| Callback_fn(a) }
and use this block in my c-routines (in my dll).
And I need the block in another function!
In my wrapping-init function (in the dll, c-code)
the block is there and rb_yield does the right things.
But in another function (my thread)
rb_block_given_p
says there is no block and so I can’t do rb_yield.
But I need the block in the thread…
I’v tried some things like the example in the ruby-html-docu
(the CD-Player…) but rb_block_given_p fails (in my thread).
Also:
In the c-function which wrapped rPAInit the block is there.
In my thread the block is not there - but I need the the block
in my thread. I don’t know how to redirect the block…
It’s all c-code
and use this block in my c-routines (in my dll).
And I need the block in another function!
Well there are 2 possibilities
* the 2 functions are ruby method : in this case, this is just my
previous example. You store the block in an instance variable when
rPAInit is called and then call it in the second method
* only rPAInit is a ruby method, the second function is just a C method
called. In this case you use a thread local variable.
rPAInit() store the block (rb_thread_local_aset()) and the second
function retrieve it (rb_thread_local_aref()) and call it