Re: gthread-win32.c



Sebastian Wilhelmi wrote:

Hi Kaz, Dan, Steven and all interested parties.

We now have a native thread implementation for win32. Everything was quite
straightforward once I got used to the different calling conventions in
windows (Argh....!). The only challange were the condition varibales. They are
modelled after what Kaz proposed, I think it's called "Explicit Notification".
Using GArrays instead of GLists they should be quite efficient....

Please have a look to avoid any loopholes in this implementation.

http://cvs.gnome.org/bonsai/cvsblame.cgi?file=glib/gthread/gthread-win32.c

Thanks,
Sebastian


234                if (retval == WAIT_TIMEOUT)
235                  {
236                    EnterCriticalSection (&cond->lock);
237                    g_ptr_array_remove (cond->array, event);
238
239 /* In the meantime we could have been signaled, so we must again 240 * wait for the signal, this time with no timeout, to reset it */ 241 win32_check_for_error (WAIT_FAILED != WaitForSingleObject (event, 0));
242
243                    LeaveCriticalSection (&cond->lock);
244                  }

Should this not change retval?  If the object has been signalled, then
it should return successful.  Otherwise, the event which caused the
object to be signalled is lost.


462 retval->thread = (HANDLE) _beginthreadex (NULL, stack_size, g_thread_proxy,
463 wilhelmi 1.1 retval, 0, &ignore);

Interesting.  Why not use CreateThread?

Steven





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