Replace some usage of EventWrapper with rtc::Event.

Bug: webrtc:3380
Change-Id: Id33b19bf107273e6f838aa633784db73d02ae2c2
Reviewed-on: https://webrtc-review.googlesource.com/c/107888
Reviewed-by: Henrik Grunell <henrikg@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25407}
This commit is contained in:
Niels Möller
2018-10-29 09:47:51 +01:00
committed by Commit Bot
parent 88d8d7d3f9
commit 2c16cc61c2
10 changed files with 74 additions and 101 deletions

View File

@ -35,6 +35,7 @@
#include "modules/audio_coding/neteq/tools/packet.h"
#include "modules/audio_coding/neteq/tools/rtp_file_source.h"
#include "rtc_base/criticalsection.h"
#include "rtc_base/event.h"
#include "rtc_base/messagedigest.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/platform_thread.h"
@ -42,7 +43,6 @@
#include "rtc_base/system/arch.h"
#include "rtc_base/thread_annotations.h"
#include "system_wrappers/include/clock.h"
#include "system_wrappers/include/event_wrapper.h"
#include "system_wrappers/include/sleep.h"
#include "test/gtest.h"
#include "test/mock_audio_decoder.h"
@ -481,7 +481,7 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
send_thread_(CbSendThread, this, "send"),
insert_packet_thread_(CbInsertPacketThread, this, "insert_packet"),
pull_audio_thread_(CbPullAudioThread, this, "pull_audio"),
test_complete_(EventWrapper::Create()),
test_complete_(false, false),
send_count_(0),
insert_packet_count_(0),
pull_audio_count_(0),
@ -512,8 +512,8 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
insert_packet_thread_.Stop();
}
EventTypeWrapper RunTest() {
return test_complete_->Wait(10 * 60 * 1000); // 10 minutes' timeout.
bool RunTest() {
return test_complete_.Wait(10 * 60 * 1000); // 10 minutes' timeout.
}
virtual bool TestDone() {
@ -538,12 +538,12 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
SleepMs(1);
if (HasFatalFailure()) {
// End the test early if a fatal failure (ASSERT_*) has occurred.
test_complete_->Set();
test_complete_.Set();
}
++send_count_;
InsertAudioAndVerifyEncoding();
if (TestDone()) {
test_complete_->Set();
test_complete_.Set();
}
return true;
}
@ -592,7 +592,7 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
rtc::PlatformThread send_thread_;
rtc::PlatformThread insert_packet_thread_;
rtc::PlatformThread pull_audio_thread_;
const std::unique_ptr<EventWrapper> test_complete_;
rtc::Event test_complete_;
int send_count_;
int insert_packet_count_;
int pull_audio_count_ RTC_GUARDED_BY(crit_sect_);
@ -607,7 +607,7 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
#define MAYBE_DoTest DoTest
#endif
TEST_F(AudioCodingModuleMtTestOldApi, MAYBE_DoTest) {
EXPECT_EQ(kEventSignaled, RunTest());
EXPECT_TRUE(RunTest());
}
// This is a multi-threaded ACM test using iSAC. The test encodes audio
@ -717,7 +717,7 @@ class AcmIsacMtTestOldApi : public AudioCodingModuleMtTestOldApi {
#endif
#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
TEST_F(AcmIsacMtTestOldApi, MAYBE_DoTest) {
EXPECT_EQ(kEventSignaled, RunTest());
EXPECT_TRUE(RunTest());
}
#endif
@ -734,7 +734,7 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
codec_registration_thread_(CbCodecRegistrationThread,
this,
"codec_registration"),
test_complete_(EventWrapper::Create()),
test_complete_(false, false),
codec_registered_(false),
receive_packet_count_(0),
next_insert_packet_time_ms_(0),
@ -781,8 +781,8 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
codec_registration_thread_.Stop();
}
EventTypeWrapper RunTest() {
return test_complete_->Wait(10 * 60 * 1000); // 10 minutes' timeout.
bool RunTest() {
return test_complete_.Wait(10 * 60 * 1000); // 10 minutes' timeout.
}
static bool CbReceiveThread(void* context) {
@ -845,7 +845,7 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
SleepMs(1);
if (HasFatalFailure()) {
// End the test early if a fatal failure (ASSERT_*) has occurred.
test_complete_->Set();
test_complete_.Set();
}
rtc::CritScope lock(&crit_sect_);
if (!codec_registered_ &&
@ -856,14 +856,14 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
codec_registered_ = true;
}
if (codec_registered_ && receive_packet_count_ > kNumPackets) {
test_complete_->Set();
test_complete_.Set();
}
return true;
}
rtc::PlatformThread receive_thread_;
rtc::PlatformThread codec_registration_thread_;
const std::unique_ptr<EventWrapper> test_complete_;
rtc::Event test_complete_;
rtc::CriticalSection crit_sect_;
bool codec_registered_ RTC_GUARDED_BY(crit_sect_);
int receive_packet_count_ RTC_GUARDED_BY(crit_sect_);
@ -880,7 +880,7 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
#endif
#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
TEST_F(AcmReRegisterIsacMtTestOldApi, MAYBE_DoTest) {
EXPECT_EQ(kEventSignaled, RunTest());
EXPECT_TRUE(RunTest());
}
#endif

View File

@ -26,7 +26,6 @@ class PlatformThread;
} // namespace rtc
namespace webrtc {
class EventWrapper;
// This is a fake audio device which plays audio from a file as its microphone
// and plays out into a file.

View File

@ -29,7 +29,6 @@ typedef webrtc::adm_linux_alsa::AlsaSymbolTable WebRTCAlsaSymbolTable;
WebRTCAlsaSymbolTable* GetAlsaSymbolTable();
namespace webrtc {
class EventWrapper;
class AudioDeviceLinuxALSA : public AudioDeviceGeneric {
public:

View File

@ -14,7 +14,6 @@
#include "modules/audio_device/linux/latebindingsymboltable_linux.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "system_wrappers/include/event_wrapper.h"
WebRTCPulseSymbolTable* GetPulseSymbolTable() {
static WebRTCPulseSymbolTable* pulse_symbol_table =
@ -33,10 +32,10 @@ namespace webrtc {
AudioDeviceLinuxPulse::AudioDeviceLinuxPulse()
: _ptrAudioBuffer(NULL),
_timeEventRec(*EventWrapper::Create()),
_timeEventPlay(*EventWrapper::Create()),
_recStartEvent(*EventWrapper::Create()),
_playStartEvent(*EventWrapper::Create()),
_timeEventRec(false, false),
_timeEventPlay(false, false),
_recStartEvent(false, false),
_playStartEvent(false, false),
_inputDeviceIndex(0),
_outputDeviceIndex(0),
_inputDeviceIsSpecified(false),
@ -113,11 +112,6 @@ AudioDeviceLinuxPulse::~AudioDeviceLinuxPulse() {
delete[] _recDeviceName;
_recDeviceName = NULL;
}
delete &_recStartEvent;
delete &_playStartEvent;
delete &_timeEventRec;
delete &_timeEventPlay;
}
void AudioDeviceLinuxPulse::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
@ -1067,7 +1061,7 @@ int32_t AudioDeviceLinuxPulse::StartRecording() {
// The audio thread will signal when recording has started.
_timeEventRec.Set();
if (kEventTimeout == _recStartEvent.Wait(10000)) {
if (!_recStartEvent.Wait(10000)) {
{
rtc::CritScope lock(&_critSect);
_startRec = false;
@ -1182,7 +1176,7 @@ int32_t AudioDeviceLinuxPulse::StartPlayout() {
// The audio thread will signal when playout has started.
_timeEventPlay.Set();
if (kEventTimeout == _playStartEvent.Wait(10000)) {
if (!_playStartEvent.Wait(10000)) {
{
rtc::CritScope lock(&_critSect);
_startPlay = false;
@ -1996,14 +1990,8 @@ bool AudioDeviceLinuxPulse::RecThreadFunc(void* pThis) {
}
bool AudioDeviceLinuxPulse::PlayThreadProcess() {
switch (_timeEventPlay.Wait(1000)) {
case kEventSignaled:
break;
case kEventError:
RTC_LOG(LS_WARNING) << "EventWrapper::Wait() failed";
return true;
case kEventTimeout:
return true;
if (!_timeEventPlay.Wait(1000)) {
return true;
}
rtc::CritScope lock(&_critSect);
@ -2170,14 +2158,8 @@ bool AudioDeviceLinuxPulse::PlayThreadProcess() {
}
bool AudioDeviceLinuxPulse::RecThreadProcess() {
switch (_timeEventRec.Wait(1000)) {
case kEventSignaled:
break;
case kEventError:
RTC_LOG(LS_WARNING) << "EventWrapper::Wait() failed";
return true;
case kEventTimeout:
return true;
if (!_timeEventRec.Wait(1000)) {
return true;
}
rtc::CritScope lock(&_critSect);

View File

@ -20,6 +20,7 @@
#include "modules/audio_device/linux/audio_mixer_manager_pulse_linux.h"
#include "modules/audio_device/linux/pulseaudiosymboltable_linux.h"
#include "rtc_base/criticalsection.h"
#include "rtc_base/event.h"
#include "rtc_base/platform_thread.h"
#include "rtc_base/thread_annotations.h"
#include "rtc_base/thread_checker.h"
@ -103,7 +104,6 @@ typedef webrtc::adm_linux_pulse::PulseAudioSymbolTable WebRTCPulseSymbolTable;
WebRTCPulseSymbolTable* GetPulseSymbolTable();
namespace webrtc {
class EventWrapper;
class AudioDeviceLinuxPulse : public AudioDeviceGeneric {
public:
@ -262,10 +262,10 @@ class AudioDeviceLinuxPulse : public AudioDeviceGeneric {
AudioDeviceBuffer* _ptrAudioBuffer;
rtc::CriticalSection _critSect;
EventWrapper& _timeEventRec;
EventWrapper& _timeEventPlay;
EventWrapper& _recStartEvent;
EventWrapper& _playStartEvent;
rtc::Event _timeEventRec;
rtc::Event _timeEventPlay;
rtc::Event _recStartEvent;
rtc::Event _playStartEvent;
// TODO(pbos): Remove unique_ptr and use directly without resetting.
std::unique_ptr<rtc::PlatformThread> _ptrThreadPlay;

View File

@ -18,11 +18,11 @@
#include "api/array_view.h"
#include "modules/audio_processing/test/test_utils.h"
#include "rtc_base/atomicops.h"
#include "rtc_base/event.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/platform_thread.h"
#include "rtc_base/random.h"
#include "system_wrappers/include/clock.h"
#include "system_wrappers/include/event_wrapper.h"
#include "test/gtest.h"
#include "test/testsupport/perf_test.h"
@ -391,7 +391,7 @@ class TimedThreadApiProcessor {
class CallSimulator : public ::testing::TestWithParam<SimulationConfig> {
public:
CallSimulator()
: test_complete_(EventWrapper::Create()),
: test_complete_(false, false),
render_thread_(
new rtc::PlatformThread(RenderProcessorThreadFunc, this, "render")),
capture_thread_(new rtc::PlatformThread(CaptureProcessorThreadFunc,
@ -401,10 +401,10 @@ class CallSimulator : public ::testing::TestWithParam<SimulationConfig> {
simulation_config_(static_cast<SimulationConfig>(GetParam())) {}
// Run the call simulation with a timeout.
EventTypeWrapper Run() {
bool Run() {
StartThreads();
EventTypeWrapper result = test_complete_->Wait(kTestTimeout);
bool result = test_complete_.Wait(kTestTimeout);
StopThreads();
@ -420,7 +420,7 @@ class CallSimulator : public ::testing::TestWithParam<SimulationConfig> {
// done.
bool MaybeEndTest() {
if (frame_counters_.BothCountersExceedeThreshold(kMinNumFramesToProcess)) {
test_complete_->Set();
test_complete_.Set();
return true;
}
return false;
@ -570,7 +570,7 @@ class CallSimulator : public ::testing::TestWithParam<SimulationConfig> {
}
// Event handler for the test.
const std::unique_ptr<EventWrapper> test_complete_;
rtc::Event test_complete_;
// Thread related variables.
std::unique_ptr<rtc::PlatformThread> render_thread_;
@ -619,7 +619,7 @@ const float CallSimulator::kCaptureInputFloatLevel = 0.03125f;
// TODO(peah): Reactivate once issue 7712 has been resolved.
TEST_P(CallSimulator, DISABLED_ApiCallDurationTest) {
// Run test and verify that it did not time out.
EXPECT_EQ(kEventSignaled, Run());
EXPECT_TRUE(Run());
}
INSTANTIATE_TEST_CASE_P(

View File

@ -44,7 +44,7 @@ std::unique_ptr<ProcessThread> ProcessThread::Create(const char* thread_name) {
}
ProcessThreadImpl::ProcessThreadImpl(const char* thread_name)
: wake_up_(EventWrapper::Create()),
: wake_up_(/*manual_reset=*/false, /*initially_signaled=*/false),
stop_(false),
thread_name_(thread_name) {}
@ -85,7 +85,7 @@ void ProcessThreadImpl::Stop() {
stop_ = true;
}
wake_up_->Set();
wake_up_.Set();
thread_->Stop();
stop_ = false;
@ -104,7 +104,7 @@ void ProcessThreadImpl::WakeUp(Module* module) {
m.next_callback = kCallProcessImmediately;
}
}
wake_up_->Set();
wake_up_.Set();
}
void ProcessThreadImpl::PostTask(std::unique_ptr<rtc::QueuedTask> task) {
@ -113,7 +113,7 @@ void ProcessThreadImpl::PostTask(std::unique_ptr<rtc::QueuedTask> task) {
rtc::CritScope lock(&lock_);
queue_.push(task.release());
}
wake_up_->Set();
wake_up_.Set();
}
void ProcessThreadImpl::RegisterModule(Module* module,
@ -147,7 +147,7 @@ void ProcessThreadImpl::RegisterModule(Module* module,
// Wake the thread calling ProcessThreadImpl::Process() to update the
// waiting time. The waiting time for the just registered module may be
// shorter than all other registered modules.
wake_up_->Set();
wake_up_.Set();
}
void ProcessThreadImpl::DeRegisterModule(Module* module) {
@ -217,7 +217,7 @@ bool ProcessThreadImpl::Process() {
int64_t time_to_wait = next_checkpoint - rtc::TimeMillis();
if (time_to_wait > 0)
wake_up_->Wait(static_cast<unsigned long>(time_to_wait));
wake_up_.Wait(static_cast<int>(time_to_wait));
return true;
}

View File

@ -19,11 +19,11 @@
#include "modules/include/module.h"
#include "modules/utility/include/process_thread.h"
#include "rtc_base/criticalsection.h"
#include "rtc_base/event.h"
#include "rtc_base/location.h"
#include "rtc_base/platform_thread.h"
#include "rtc_base/task_queue.h"
#include "rtc_base/thread_checker.h"
#include "system_wrappers/include/event_wrapper.h"
namespace webrtc {
@ -75,7 +75,7 @@ class ProcessThreadImpl : public ProcessThread {
rtc::CriticalSection lock_; // Used to guard modules_, tasks_ and stop_.
rtc::ThreadChecker thread_checker_;
const std::unique_ptr<EventWrapper> wake_up_;
rtc::Event wake_up_;
// TODO(pbos): Remove unique_ptr and stop recreating the thread.
std::unique_ptr<rtc::PlatformThread> thread_;

View File

@ -42,14 +42,14 @@ class MockModule : public Module {
class RaiseEventTask : public rtc::QueuedTask {
public:
RaiseEventTask(EventWrapper* event) : event_(event) {}
RaiseEventTask(rtc::Event* event) : event_(event) {}
bool Run() override {
event_->Set();
return true;
}
private:
EventWrapper* event_;
rtc::Event* event_;
};
ACTION_P(SetEvent, event) {
@ -83,19 +83,19 @@ TEST(ProcessThreadImpl, ProcessCall) {
ProcessThreadImpl thread("ProcessThread");
thread.Start();
std::unique_ptr<EventWrapper> event(EventWrapper::Create());
rtc::Event event(false, false);
MockModule module;
EXPECT_CALL(module, TimeUntilNextProcess())
.WillOnce(Return(0))
.WillRepeatedly(Return(1));
EXPECT_CALL(module, Process())
.WillOnce(DoAll(SetEvent(event.get()), Return()))
.WillOnce(DoAll(SetEvent(&event), Return()))
.WillRepeatedly(Return());
EXPECT_CALL(module, ProcessThreadAttached(&thread)).Times(1);
thread.RegisterModule(&module, RTC_FROM_HERE);
EXPECT_EQ(kEventSignaled, event->Wait(kEventWaitTimeout));
EXPECT_TRUE(event.Wait(kEventWaitTimeout));
EXPECT_CALL(module, ProcessThreadAttached(nullptr)).Times(1);
thread.Stop();
@ -105,21 +105,21 @@ TEST(ProcessThreadImpl, ProcessCall) {
// call to Start().
TEST(ProcessThreadImpl, ProcessCall2) {
ProcessThreadImpl thread("ProcessThread");
std::unique_ptr<EventWrapper> event(EventWrapper::Create());
rtc::Event event(false, false);
MockModule module;
EXPECT_CALL(module, TimeUntilNextProcess())
.WillOnce(Return(0))
.WillRepeatedly(Return(1));
EXPECT_CALL(module, Process())
.WillOnce(DoAll(SetEvent(event.get()), Return()))
.WillOnce(DoAll(SetEvent(&event), Return()))
.WillRepeatedly(Return());
thread.RegisterModule(&module, RTC_FROM_HERE);
EXPECT_CALL(module, ProcessThreadAttached(&thread)).Times(1);
thread.Start();
EXPECT_EQ(kEventSignaled, event->Wait(kEventWaitTimeout));
EXPECT_TRUE(event.Wait(kEventWaitTimeout));
EXPECT_CALL(module, ProcessThreadAttached(nullptr)).Times(1);
thread.Stop();
@ -129,7 +129,7 @@ TEST(ProcessThreadImpl, ProcessCall2) {
// After unregistration, we should not receive any further callbacks.
TEST(ProcessThreadImpl, Deregister) {
ProcessThreadImpl thread("ProcessThread");
std::unique_ptr<EventWrapper> event(EventWrapper::Create());
rtc::Event event(false, false);
int process_count = 0;
MockModule module;
@ -137,8 +137,7 @@ TEST(ProcessThreadImpl, Deregister) {
.WillOnce(Return(0))
.WillRepeatedly(Return(1));
EXPECT_CALL(module, Process())
.WillOnce(
DoAll(SetEvent(event.get()), Increment(&process_count), Return()))
.WillOnce(DoAll(SetEvent(&event), Increment(&process_count), Return()))
.WillRepeatedly(DoAll(Increment(&process_count), Return()));
thread.RegisterModule(&module, RTC_FROM_HERE);
@ -146,7 +145,7 @@ TEST(ProcessThreadImpl, Deregister) {
EXPECT_CALL(module, ProcessThreadAttached(&thread)).Times(1);
thread.Start();
EXPECT_EQ(kEventSignaled, event->Wait(kEventWaitTimeout));
EXPECT_TRUE(event.Wait(kEventWaitTimeout));
EXPECT_CALL(module, ProcessThreadAttached(nullptr)).Times(1);
thread.DeRegisterModule(&module);
@ -155,7 +154,7 @@ TEST(ProcessThreadImpl, Deregister) {
int count_after_deregister = process_count;
// We shouldn't get any more callbacks.
EXPECT_EQ(kEventTimeout, event->Wait(20));
EXPECT_FALSE(event.Wait(20));
EXPECT_EQ(count_after_deregister, process_count);
thread.Stop();
}
@ -167,7 +166,7 @@ void ProcessCallAfterAFewMs(int64_t milliseconds) {
ProcessThreadImpl thread("ProcessThread");
thread.Start();
std::unique_ptr<EventWrapper> event(EventWrapper::Create());
rtc::Event event(false, false);
MockModule module;
int64_t start_time = 0;
@ -176,8 +175,7 @@ void ProcessCallAfterAFewMs(int64_t milliseconds) {
.WillOnce(DoAll(SetTimestamp(&start_time), Return(milliseconds)))
.WillRepeatedly(Return(milliseconds));
EXPECT_CALL(module, Process())
.WillOnce(
DoAll(SetTimestamp(&called_time), SetEvent(event.get()), Return()))
.WillOnce(DoAll(SetTimestamp(&called_time), SetEvent(&event), Return()))
.WillRepeatedly(Return());
EXPECT_CALL(module, ProcessThreadAttached(&thread)).Times(1);
@ -185,7 +183,7 @@ void ProcessCallAfterAFewMs(int64_t milliseconds) {
// Add a buffer of 50ms due to slowness of some trybots
// (e.g. win_drmemory_light)
EXPECT_EQ(kEventSignaled, event->Wait(milliseconds + 50));
EXPECT_TRUE(event.Wait(milliseconds + 50));
EXPECT_CALL(module, ProcessThreadAttached(nullptr)).Times(1);
thread.Stop();
@ -230,7 +228,7 @@ TEST(ProcessThreadImpl, DISABLED_Process50Times) {
ProcessThreadImpl thread("ProcessThread");
thread.Start();
std::unique_ptr<EventWrapper> event(EventWrapper::Create());
rtc::Event event(false, false);
MockModule module;
int callback_count = 0;
@ -242,7 +240,7 @@ TEST(ProcessThreadImpl, DISABLED_Process50Times) {
EXPECT_CALL(module, ProcessThreadAttached(&thread)).Times(1);
thread.RegisterModule(&module, RTC_FROM_HERE);
EXPECT_EQ(kEventTimeout, event->Wait(1000));
EXPECT_TRUE(event.Wait(1000));
EXPECT_CALL(module, ProcessThreadAttached(nullptr)).Times(1);
thread.Stop();
@ -261,8 +259,8 @@ TEST(ProcessThreadImpl, WakeUp) {
ProcessThreadImpl thread("ProcessThread");
thread.Start();
std::unique_ptr<EventWrapper> started(EventWrapper::Create());
std::unique_ptr<EventWrapper> called(EventWrapper::Create());
rtc::Event started(false, false);
rtc::Event called(false, false);
MockModule module;
int64_t start_time;
@ -276,20 +274,19 @@ TEST(ProcessThreadImpl, WakeUp) {
// The second time TimeUntilNextProcess is then called, is after Process
// has been called and we don't expect any more calls.
EXPECT_CALL(module, TimeUntilNextProcess())
.WillOnce(DoAll(SetTimestamp(&start_time), SetEvent(started.get()),
Return(1000)))
.WillOnce(
DoAll(SetTimestamp(&start_time), SetEvent(&started), Return(1000)))
.WillOnce(Return(1000));
EXPECT_CALL(module, Process())
.WillOnce(
DoAll(SetTimestamp(&called_time), SetEvent(called.get()), Return()))
.WillOnce(DoAll(SetTimestamp(&called_time), SetEvent(&called), Return()))
.WillRepeatedly(Return());
EXPECT_CALL(module, ProcessThreadAttached(&thread)).Times(1);
thread.RegisterModule(&module, RTC_FROM_HERE);
EXPECT_EQ(kEventSignaled, started->Wait(kEventWaitTimeout));
EXPECT_TRUE(started.Wait(kEventWaitTimeout));
thread.WakeUp(&module);
EXPECT_EQ(kEventSignaled, called->Wait(kEventWaitTimeout));
EXPECT_TRUE(called.Wait(kEventWaitTimeout));
EXPECT_CALL(module, ProcessThreadAttached(nullptr)).Times(1);
thread.Stop();
@ -304,11 +301,11 @@ TEST(ProcessThreadImpl, WakeUp) {
// thread.
TEST(ProcessThreadImpl, PostTask) {
ProcessThreadImpl thread("ProcessThread");
std::unique_ptr<EventWrapper> task_ran(EventWrapper::Create());
std::unique_ptr<RaiseEventTask> task(new RaiseEventTask(task_ran.get()));
rtc::Event task_ran(false, false);
std::unique_ptr<RaiseEventTask> task(new RaiseEventTask(&task_ran));
thread.Start();
thread.PostTask(std::move(task));
EXPECT_EQ(kEventSignaled, task_ran->Wait(kEventWaitTimeout));
EXPECT_TRUE(task_ran.Wait(kEventWaitTimeout));
thread.Stop();
}

View File

@ -12,11 +12,7 @@
#define SYSTEM_WRAPPERS_INCLUDE_EVENT_WRAPPER_H_
namespace webrtc {
enum EventTypeWrapper {
kEventSignaled = 1,
kEventError = 2,
kEventTimeout = 3
};
enum EventTypeWrapper { kEventSignaled = 1, kEventTimeout = 2 };
#define WEBRTC_EVENT_INFINITE 0xffffffff