• Kevin Modzelewski's avatar
    Improve threading fairness · df0a8454
    Kevin Modzelewski authored
    Previously, to allow other threads to acquire the GIL, we would
    just do a "releaseGIL(); acquireGIL();" and hope that another thread
    would grab it.  The current thread has the best chance of grabbing the
    GIL again, so I think what's been happening is that it would tend to
    win the race to reacquire and starve all the other threads.
    
    Now, the current thread is forced to wait for at least one other
    thread to acquire the GIL before it can reaquire it.  This means that
    we're at least fair between two threads, though not necessarily fair
    between more than that (but at least it's more random and not as stacked
    towards being unfair).
    df0a8454
threading.cpp 15.3 KB