[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT + Pluto coroutine issue
- From: Mike Pall <mikelu-0512@...>
- Date: Tue, 6 Dec 2005 20:24:12 +0100
Hi,
Jan Reijnen wrote:
> On XP it returns always the same value 00001E00 and never NULL.
Argh ... a part of the explanation is in this MSDN blog entry
(way down in the text and in the comments):
http://blogs.msdn.com/oldnewthing/archive/2004/12/31/344799.aspx
Seems there is no proper way to detect whether a thread has been
converted to a fiber without managing this on your own (with a
thread local variable). But some other library may have already
done so and doesn't know about this ...
Vista supposedly has IsThreadAFiber(), but we've to struggle with
XP right now. The way Lua is used, I cannot predict or dictate
from which thread a coroutine is (to be) resumed. So I really
need a (fast and non-leaky) way to convert a thread to a fiber on
demand.
I think I'll have to settle on this unclean solution:
{ void *cur = GetCurrentFiber(); \
if (cur == NULL || cur == (void *)0x1e00) ConvertThreadToFiber(NULL); } \
[The 0x1e00 seems to be a constant. Ok, don't shoot me -- MS
messed it up in the first place.]
Thanks Jan for pointing out this problem!
Bye,
Mike