Move rtc::Event to rtc_base_approved. We need an event implementation in WebRTC that allows us to specify whether it's manually reset or automatically. EventWrapper currently doesn't support it and it adds a heap allocation + vtable, so rtc::Event is the lighter of the two.
I'm also tidying rtc::Event up a bit. Removing member variable that's not needed on all platforms and moving the mutex itself up in the member list given the recent alignment scare on Mac. R=pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/38999004 Cr-Commit-Position: refs/heads/master@{#8292} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8292 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
8cf9bdb3fa
commit
4c0fd965ce
@ -105,6 +105,8 @@ static_library("rtc_base_approved") {
|
||||
sources = [
|
||||
"checks.cc",
|
||||
"checks.h",
|
||||
"event.cc",
|
||||
"event.h",
|
||||
"exp_filter.cc",
|
||||
"exp_filter.h",
|
||||
"md5.cc",
|
||||
@ -181,8 +183,6 @@ static_library("rtc_base") {
|
||||
"cryptstring.h",
|
||||
"diskcache.cc",
|
||||
"diskcache.h",
|
||||
"event.cc",
|
||||
"event.h",
|
||||
"fileutils.cc",
|
||||
"fileutils.h",
|
||||
"firewallsocketserver.cc",
|
||||
|
||||
@ -31,6 +31,8 @@
|
||||
'sources': [
|
||||
'checks.cc',
|
||||
'checks.h',
|
||||
'event.cc',
|
||||
'event.h',
|
||||
'exp_filter.cc',
|
||||
'exp_filter.h',
|
||||
'md5.cc',
|
||||
@ -112,8 +114,6 @@
|
||||
'diskcache.h',
|
||||
'diskcache_win32.cc',
|
||||
'diskcache_win32.h',
|
||||
'event.cc',
|
||||
'event.h',
|
||||
'filelock.cc',
|
||||
'filelock.h',
|
||||
'fileutils.cc',
|
||||
|
||||
@ -20,18 +20,18 @@
|
||||
#error "Must define either WEBRTC_WIN or WEBRTC_POSIX."
|
||||
#endif
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
|
||||
Event::Event(bool manual_reset, bool initially_signaled)
|
||||
: is_manual_reset_(manual_reset),
|
||||
is_initially_signaled_(initially_signaled) {
|
||||
Event::Event(bool manual_reset, bool initially_signaled) {
|
||||
event_handle_ = ::CreateEvent(NULL, // Security attributes.
|
||||
is_manual_reset_,
|
||||
is_initially_signaled_,
|
||||
manual_reset,
|
||||
initially_signaled,
|
||||
NULL); // Name.
|
||||
ASSERT(event_handle_ != NULL);
|
||||
CHECK(event_handle_);
|
||||
}
|
||||
|
||||
Event::~Event() {
|
||||
@ -47,7 +47,7 @@ void Event::Reset() {
|
||||
}
|
||||
|
||||
bool Event::Wait(int cms) {
|
||||
DWORD ms = (cms == kForever)? INFINITE : cms;
|
||||
DWORD ms = (cms == kForever) ? INFINITE : cms;
|
||||
return (WaitForSingleObject(event_handle_, ms) == WAIT_OBJECT_0);
|
||||
}
|
||||
|
||||
@ -56,8 +56,8 @@ bool Event::Wait(int cms) {
|
||||
Event::Event(bool manual_reset, bool initially_signaled)
|
||||
: is_manual_reset_(manual_reset),
|
||||
event_status_(initially_signaled) {
|
||||
VERIFY(pthread_mutex_init(&event_mutex_, NULL) == 0);
|
||||
VERIFY(pthread_cond_init(&event_cond_, NULL) == 0);
|
||||
CHECK(pthread_mutex_init(&event_mutex_, NULL) == 0);
|
||||
CHECK(pthread_cond_init(&event_cond_, NULL) == 0);
|
||||
}
|
||||
|
||||
Event::~Event() {
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
#endif
|
||||
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/base/common.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
@ -34,15 +33,13 @@ class Event {
|
||||
bool Wait(int cms);
|
||||
|
||||
private:
|
||||
bool is_manual_reset_;
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
bool is_initially_signaled_;
|
||||
HANDLE event_handle_;
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
bool event_status_;
|
||||
pthread_mutex_t event_mutex_;
|
||||
pthread_cond_t event_cond_;
|
||||
const bool is_manual_reset_;
|
||||
bool event_status_;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user