Ignore:
Timestamp:
Dec 30, 2013, 4:30:11 PM (11 years ago)
Author:
[email protected]
Message:

Stop using ThreadCondition in jsc.cpp
https://bugs.webkit.org/show_bug.cgi?id=126311

Reviewed by Sam Weinig.

  • jsc.cpp:

(timeoutThreadMain):
(main):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jsc.cpp

    r160550 r161159  
    4848#include <stdlib.h>
    4949#include <string.h>
     50#include <thread>
    5051#include <wtf/CurrentTime.h>
    5152#include <wtf/MainThread.h>
     
    550551
    551552static double s_desiredTimeout;
    552 static double s_timeToWake;
    553553
    554554static NO_RETURN_DUE_TO_CRASH void timeoutThreadMain(void*)
    555555{
    556     // WTF doesn't provide for a portable sleep(), so we use the ThreadCondition, which
    557     // is close enough.
    558     Mutex mutex;
    559     ThreadCondition condition;
    560     mutex.lock();
    561     while (currentTime() < s_timeToWake)
    562         condition.timedWait(mutex, s_timeToWake);
     556    auto timeout = std::chrono::microseconds(static_cast<std::chrono::microseconds::rep>(s_desiredTimeout * 1000000));
     557    std::this_thread::sleep_for(timeout);
    563558   
    564559    dataLog("Timed out after ", s_desiredTimeout, " seconds!\n");
     
    617612                "WARNING: timeout string is malformed, got ", timeoutString,
    618613                " but expected a number. Not using a timeout.\n");
    619         } else {
    620             s_timeToWake = currentTime() + s_desiredTimeout;
     614        } else
    621615            createThread(timeoutThreadMain, 0, "jsc Timeout Thread");
    622         }
    623616    }
    624617#endif
Note: See TracChangeset for help on using the changeset viewer.