Commit aba1020d by Ben Clayton

Remove the now unused sw::Event.

Bug: b/140546382 Change-Id: I71253f73dcd3c2083873cb1f0084b42190e9df8e Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/38209Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 0fde10b2
...@@ -117,101 +117,6 @@ private: ...@@ -117,101 +117,6 @@ private:
std::condition_variable condition; std::condition_variable condition;
}; };
// Event is a synchronization mechanism used to indicate to waiting threads
// when a boolean condition has become true.
class Event
{
public:
enum class ClearMode
{
// The event signal will be automatically reset when a call to wait()
// returns.
// A single call to signal() will only unblock a single (possibly
// pending) call to wait().
Auto,
// The event will remain in the signaled state when calling signal().
// While the event is in the signaled state, any calls to wait() will
// unblock without automatically reseting the signaled state.
// The signaled state can be reset with a call to clear().
Manual
};
Event(ClearMode mode = ClearMode::Auto, bool initialState = false)
: mode(mode), signaled(initialState) {}
// signal() signals the event, unblocking any calls to wait().
void signal()
{
std::unique_lock<std::mutex> lock(mutex);
signaled = true;
if (mode == ClearMode::Auto)
{
condition.notify_one();
}
else
{
condition.notify_all();
}
}
// clear() sets the event signal to false.
void clear()
{
std::unique_lock<std::mutex> lock(mutex);
signaled = false;
}
// wait() blocks until all the event signal is set to true.
// If the event was constructed with the Auto ClearMode, then the signal
// is cleared before returning.
void wait()
{
std::unique_lock<std::mutex> lock(mutex);
condition.wait(lock, [this] { return signaled; });
if (mode == ClearMode::Auto)
{
signaled = false;
}
}
// wait() blocks until the event signal is set to true or the timeout
// has been reached, returning true if signal was raised, or false if the
// timeout has been reached.
// If the event was constructed with the Auto ClearMode and the wait did
// not time out, then the signal is cleared before returning.
template <class CLOCK, class DURATION>
bool wait(const std::chrono::time_point<CLOCK, DURATION>& timeout)
{
std::unique_lock<std::mutex> lock(mutex);
if (!condition.wait_until(lock, timeout, [this] { return signaled; }))
{
return false;
}
if (mode == ClearMode::Auto)
{
signaled = false;
}
return true;
}
// bool() returns true if the event is signaled, otherwise false.
// Note: No lock is held after bool() returns, so the event state may
// immediately change after returning.
operator bool()
{
std::unique_lock<std::mutex> lock(mutex);
return signaled;
}
public:
const ClearMode mode;
bool signaled; // guarded by mutex
std::mutex mutex;
std::condition_variable condition;
};
// Chan is a thread-safe FIFO queue of type T. // Chan is a thread-safe FIFO queue of type T.
// Chan takes its name after Golang's chan. // Chan takes its name after Golang's chan.
template <typename T> template <typename T>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment