Author: Armin Rigo <[email protected]>
Branch: gil-improvement
Changeset: r47770:b659babedfb9
Date: 2011-10-02 18:13 +0200
http://bitbucket.org/pypy/pypy/changeset/b659babedfb9/

Log:    Move around the PulseEvents. According to the test
        (https://bitbucket.org/arigo/arigo/raw/default/hack/stm/misc) it
        still seems to be a correct placement, and it delays the PulseEvents
        as much as possible, minimizing the risks of a missed PulseEvent.

diff --git a/pypy/translator/c/src/thread_nt.h 
b/pypy/translator/c/src/thread_nt.h
--- a/pypy/translator/c/src/thread_nt.h
+++ b/pypy/translator/c/src/thread_nt.h
@@ -245,6 +245,7 @@
     if (pending_acquires <= 0)
         return 0;
     InterlockedIncrement(&pending_acquires);
+    PulseEvent(&cond_gil);
 
     /* hack: the three following lines do a pthread_cond_wait(), and
        normally specifying a timeout of INFINITE would be fine.  But the
@@ -256,13 +257,13 @@
     EnterCriticalSection(&mutex_gil);
 
     InterlockedDecrement(&pending_acquires);
-    PulseEvent(&cond_gil);
     return 1;
 }
 
 void RPyGilRelease(void)
 {
     LeaveCriticalSection(&mutex_gil);
+    PulseEvent(&cond_gil);
 }
 
 void RPyGilAcquire(void)
@@ -270,7 +271,6 @@
     InterlockedIncrement(&pending_acquires);
     EnterCriticalSection(&mutex_gil);
     InterlockedDecrement(&pending_acquires);
-    PulseEvent(&cond_gil);
 }
 
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to