lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]





----- Ursprüngliche Message -----
> Von: Thijs Schreijer <thijs@thijsschreijer.nl>
> An: Lua mailing list <lua-l@lists.lua.org>
> CC: 
> Gesendet: 7:57 Freitag, 29.März 2013
> Betreff: RE: Lua and preemptive scheduling for coroutines
> 
>>  -----Original Message-----
>>  From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
>>  Behalf Of Ross Bencina
>>  Sent: vrijdag 29 maart 2013 4:59
>>  To: Lua mailing list
>>  Subject: Re: Lua and preemptive scheduling for coroutines
>> 
>>  On 29/03/2013 2:35 PM, Tim Hill wrote:
>>  > You're not going to be able to pull that one off. The fundamental
>>  > structure of coroutines is different from threads, and nothing you do
>>  > can really change that (aside from a VERY significant reworking of the
>>  > Lua code base).
>> 
>>  I don't know about that, all he's talking about is conditionally 
> injecting
>>  yeild() into the code at arbitrary points (such as the end of each
>>  statement)
>> 
>>  This could be done manually with a syntactic substitution. The question is
>>  whether it can be done using a debug hook or similar mechanism.
>> 
>>  Ross.
> 
> I'm not sure if it can be done, but could you use the lock/unlock macros to 
> perform the yield?

Can you elaborate a bit? Where I should use such macros? In the C code? Or in Lua? 
If it is in C, can I invoke such a C-function which does lock/unlock from Lua?
And how is it different from lua_yield that can be used in C?

-Leo