lua-users home
lua-l archive

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


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):

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

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!