Changeset 161157 in webkit
- Timestamp:
- Dec 30, 2013 3:46:31 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r161156 r161157 1 2013-12-30 Anders Carlsson <andersca@apple.com> 2 3 Move more of Connection over to STL threading primitives 4 https://bugs.webkit.org/show_bug.cgi?id=126308 5 6 Reviewed by Andreas Kling. 7 8 * Platform/IPC/Connection.cpp: 9 (IPC::BinarySemaphore::BinarySemaphore): 10 (IPC::BinarySemaphore::~BinarySemaphore): 11 (IPC::BinarySemaphore::signal): 12 (IPC::BinarySemaphore::wait): 13 Add a new BinarySemaphore class that uses STL threading primitives. 14 15 (IPC::Connection::SyncMessageState::wait): 16 Change this to take a std::chrono::steady_clock::time_point. 17 18 (IPC::absoluteTimeoutTime): 19 Add a new helper function that returns a time point from the a given timeout duration, 20 correctly handling the max duration. 21 22 (IPC::Connection::sendSyncMessageFromSecondaryThread): 23 Pass a time point to SyncMessageState::wait. 24 25 (IPC::Connection::waitForSyncReply): 26 Ditto. 27 1 28 2013-12-30 Ryuan Choi <ryuan.choi@samsung.com> 2 29 -
trunk/Source/WebKit2/Platform/IPC/Connection.cpp
r161152 r161157 32 32 #include <wtf/RunLoop.h> 33 33 #include <wtf/text/WTFString.h> 34 #include <wtf/threads/BinarySemaphore.h>35 34 36 35 namespace IPC { 36 37 class BinarySemaphore { 38 public: 39 BinarySemaphore() 40 : m_isSet(false) 41 { 42 } 43 44 ~BinarySemaphore() 45 { 46 } 47 48 void signal() 49 { 50 std::lock_guard<std::mutex> lock(m_mutex); 51 52 m_isSet = true; 53 m_conditionVariable.notify_all(); 54 } 55 56 bool wait(std::chrono::steady_clock::time_point absoluteTime) 57 { 58 std::unique_lock<std::mutex> lock(m_mutex); 59 60 bool value = m_conditionVariable.wait_until(lock, absoluteTime, [this] { return m_isSet; }); 61 62 return value; 63 } 64 65 private: 66 bool m_isSet; 67 68 std::mutex m_mutex; 69 std::condition_variable m_conditionVariable; 70 }; 37 71 38 72 class Connection::SyncMessageState : public ThreadSafeRefCounted<Connection::SyncMessageState> { … … 46 80 } 47 81 48 bool wait( doubleabsoluteTime)82 bool wait(std::chrono::steady_clock::time_point absoluteTime) 49 83 { 50 84 return m_waitForSyncReplySemaphore.wait(absoluteTime); … … 377 411 } 378 412 413 static std::chrono::steady_clock::time_point absoluteTimeoutTime(std::chrono::milliseconds timeout) 414 { 415 // We use std::chrono::milliseconds::max() to mean no timeout. 416 if (timeout == std::chrono::milliseconds::max()) 417 return std::chrono::steady_clock::time_point::max(); 418 419 return std::chrono::steady_clock::now() + timeout; 420 } 421 379 422 std::unique_ptr<MessageDecoder> Connection::waitForMessage(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, std::chrono::milliseconds timeout) 380 423 { … … 501 544 sendMessage(std::move(encoder), 0); 502 545 503 pendingReply.semaphore.wait(currentTime() + (timeout.count() / 1000.0)); 546 auto timeoutTime = absoluteTimeoutTime(timeout); 547 pendingReply.semaphore.wait(timeoutTime); 504 548 505 549 // Finally, pop the pending sync reply information. … … 515 559 std::unique_ptr<MessageDecoder> Connection::waitForSyncReply(uint64_t syncRequestID, std::chrono::milliseconds timeout, unsigned syncSendFlags) 516 560 { 517 double absoluteTime = currentTime() + (timeout.count() / 1000.0);561 auto timeoutTime = absoluteTimeoutTime(timeout); 518 562 519 563 bool timedOut = false; … … 551 595 // account for a timeout value passed in. Timeout is always NoTimeout in these cases, but that could change. 552 596 RunLoop::current()->runForDuration(1e10); 553 timedOut = currentTime() >= absoluteTime;597 timedOut = std::chrono::steady_clock::now() >= timeoutTime; 554 598 #endif 555 599 } else 556 timedOut = !m_syncMessageState->wait( absoluteTime);600 timedOut = !m_syncMessageState->wait(timeoutTime); 557 601 558 602 } -
trunk/Source/WebKit2/WebProcess/WebProcess.cpp
r161148 r161157 822 822 // second timeout. That way, even if the parent decides not to add it, we'll only be 823 823 // incorrect for a little while. 824 m_plugInAutoStartOriginHashes.set(plugIn OriginHash, currentTime() + 30 * 1000);824 m_plugInAutoStartOriginHashes.set(plugIn OriginHash, currentTime() + 30 * 1000); 825 825 826 826 parentProcessConnection()->send(Messages::WebContext::AddPlugInAutoStartOriginHash(pageOrigin, plugInOriginHash), 0);
Note: See TracChangeset
for help on using the changeset viewer.