diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2016-07-28 17:32:20 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2016-07-28 17:32:20 +0000 |
commit | 2d6a9ec9351f974a19eeca4c2326ef9ff701ee37 (patch) | |
tree | e306e8382919dfd8618515a84b0cf9f495868bbf /lldb/source/Host/windows/Condition.cpp | |
parent | 5ed2b4ba1d87a8f06d7d9c5e7890d913edd44275 (diff) | |
download | bcm5719-llvm-2d6a9ec9351f974a19eeca4c2326ef9ff701ee37.tar.gz bcm5719-llvm-2d6a9ec9351f974a19eeca4c2326ef9ff701ee37.zip |
Clean up vestigial remnants of locking primitives
This finally removes the use of the Mutex and Condition classes. This is an
intricate patch as the Mutex and Condition classes were tied together.
Furthermore, many places had slightly differing uses of time values. Convert
timeout values to relative everywhere to permit the use of
std::chrono::duration, which is required for the use of
std::condition_variable's timeout. Adjust all Condition and related Mutex
classes over to std::{,recursive_}mutex and std::condition_variable.
This change primarily comes at the cost of breaking the TracingMutex which was
based around the Mutex class. It would be possible to write a wrapper to
provide similar functionality, but that is beyond the scope of this change.
llvm-svn: 277011
Diffstat (limited to 'lldb/source/Host/windows/Condition.cpp')
-rw-r--r-- | lldb/source/Host/windows/Condition.cpp | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/lldb/source/Host/windows/Condition.cpp b/lldb/source/Host/windows/Condition.cpp deleted file mode 100644 index 2f16ad77d7a..00000000000 --- a/lldb/source/Host/windows/Condition.cpp +++ /dev/null @@ -1,98 +0,0 @@ -//===-- Condition.cpp -------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include <errno.h> - -#include "lldb/Host/Condition.h" -#include "lldb/Host/TimeValue.h" -#include "lldb/Host/windows/windows.h" - - -using namespace lldb_private; - -//---------------------------------------------------------------------- -// Default constructor -// -// The default constructor will initialize a new pthread condition -// and maintain the condition in the object state. -//---------------------------------------------------------------------- -Condition::Condition () : - m_condition() -{ - m_condition = static_cast<PCONDITION_VARIABLE>(malloc(sizeof(CONDITION_VARIABLE))); - InitializeConditionVariable(static_cast<PCONDITION_VARIABLE>(m_condition)); -} - -//---------------------------------------------------------------------- -// Destructor -// -// Destroys the pthread condition that the object owns. -//---------------------------------------------------------------------- -Condition::~Condition () -{ - free(m_condition); -} - -//---------------------------------------------------------------------- -// Unblock all threads waiting for a condition variable -//---------------------------------------------------------------------- -int -Condition::Broadcast () -{ - WakeAllConditionVariable(static_cast<PCONDITION_VARIABLE>(m_condition)); - return 0; -} - -//---------------------------------------------------------------------- -// Unblocks one thread waiting for the condition variable -//---------------------------------------------------------------------- -int -Condition::Signal () -{ - WakeConditionVariable(static_cast<PCONDITION_VARIABLE>(m_condition)); - return 0; -} - -//---------------------------------------------------------------------- -// The Wait() function atomically blocks the current thread -// waiting on the owned condition variable, and unblocks the mutex -// specified by "mutex". The waiting thread unblocks only after -// another thread calls Signal(), or Broadcast() with the same -// condition variable, or if "abstime" is valid (non-NULL) this -// function will return when the system time reaches the time -// specified in "abstime". If "abstime" is NULL this function will -// wait for an infinite amount of time for the condition variable -// to be signaled or broadcasted. -// -// The current thread re-acquires the lock on "mutex". -//---------------------------------------------------------------------- -int -Condition::Wait (Mutex &mutex, const TimeValue *abstime, bool *timed_out) -{ - DWORD wait = INFINITE; - if (abstime != NULL) { - int wval = (*abstime - TimeValue::Now()) / 1000000; - if (wval < 0) wval = 0; - - wait = wval; - } - - int err = SleepConditionVariableCS(static_cast<PCONDITION_VARIABLE>(m_condition), static_cast<PCRITICAL_SECTION>(mutex.m_mutex), wait); - - if (timed_out != NULL) - { - if ((err == 0) && GetLastError() == ERROR_TIMEOUT) - *timed_out = true; - else - *timed_out = false; - } - - return err == 0; -} - |