Clean kForever from basictypes and move it to the interfaces that actually have it.

R=tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/33269004

Cr-Commit-Position: refs/heads/master@{#8296}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8296 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andresp@webrtc.org
2015-02-09 14:19:09 +00:00
parent e01bae24a5
commit 53d9012faf
17 changed files with 21 additions and 19 deletions

View File

@ -119,7 +119,7 @@ class SynchronousMethodCall
} else {
e_.reset(new rtc::Event(false, false));
t->Post(this, 0);
e_->Wait(rtc::kForever);
e_->Wait(rtc::Event::kForever);
}
}

View File

@ -224,7 +224,7 @@ VideoCapturer* DeviceManager::MaybeConstructFakeVideoCapturer(
return NULL;
}
LOG(LS_INFO) << "Created file video capturer " << device.name;
capturer->set_repeat(rtc::kForever);
capturer->set_repeat(FileVideoCapturer::kForever);
return capturer;
}

View File

@ -330,7 +330,7 @@ bool FileVideoCapturer::ReadFrame(bool first_frame, int* wait_time_ms) {
// 2.1 Read the frame header.
rtc::StreamResult result = ReadFrameHeader(&captured_frame_);
if (rtc::SR_EOS == result) { // Loop back if repeat.
if (repeat_ != rtc::kForever) {
if (repeat_ != kForever) {
if (repeat_ > 0) {
--repeat_;
} else {

View File

@ -77,6 +77,8 @@ class VideoRecorder {
// Simulated video capturer that periodically reads frames from a file.
class FileVideoCapturer : public VideoCapturer {
public:
static const int kForever = -1;
FileVideoCapturer();
virtual ~FileVideoCapturer();
@ -94,7 +96,7 @@ class FileVideoCapturer : public VideoCapturer {
}
// Set how many times to repeat reading the file. Repeat forever if the
// parameter is rtc::kForever(-1); no repeat if the parameter is 0 or
// parameter is kForever; no repeat if the parameter is 0 or
// less than -1.
void set_repeat(int repeat) { repeat_ = repeat; }

View File

@ -158,7 +158,7 @@ TEST_F(FileVideoCapturerTest, TestRepeatForever) {
VideoCapturerListener listener;
capturer_->SignalFrameCaptured.connect(
&listener, &VideoCapturerListener::OnFrameCaptured);
capturer_->set_repeat(rtc::kForever);
capturer_->set_repeat(cricket::FileVideoCapturer::kForever);
capture_format_ = capturer_->GetSupportedFormats()->at(0);
capture_format_.interval = cricket::VideoFormat::FpsToInterval(50);
EXPECT_EQ(cricket::CS_RUNNING, capturer_->Start(capture_format_));

View File

@ -318,7 +318,7 @@ class SctpDataMediaChannelTest : public testing::Test,
rtc::Thread* thread = rtc::Thread::Current();
while (!thread->empty()) {
rtc::Message msg;
if (thread->Get(&msg, rtc::kForever)) {
if (thread->Get(&msg, rtc::Thread::kForever)) {
thread->Dispatch(&msg);
}
}

View File

@ -91,7 +91,7 @@ void AsyncHttpRequest::DoWork() {
// Do nothing while we wait for the request to finish. We only do this so
// that we can be a SignalThread; in the future this class should not be
// a SignalThread, since it does not need to spawn a new thread.
Thread::Current()->ProcessMessages(kForever);
Thread::Current()->ProcessMessages(Thread::kForever);
}
void AsyncHttpRequest::LaunchRequest() {

View File

@ -55,7 +55,7 @@ void AutoDetectProxy::DoWork() {
LOG(LS_INFO) << "AutoDetectProxy initiating proxy classification";
Next();
// Process I/O until Stop()
Thread::Current()->ProcessMessages(kForever);
Thread::Current()->ProcessMessages(Thread::kForever);
// Clean up the autodetect socket, from the thread that created it
delete socket_;
}

View File

@ -114,10 +114,6 @@ typedef int socklen_t;
namespace rtc {
template<class T> inline T _min(T a, T b) { return (a > b) ? b : a; }
template<class T> inline T _max(T a, T b) { return (a < b) ? b : a; }
// For wait functions that take a number of milliseconds, kForever indicates
// unlimited time.
const int kForever = -1;
}
#define ALIGNP(p, t) \

View File

@ -25,6 +25,8 @@ namespace rtc {
class Event {
public:
static const int kForever = -1;
Event(bool manual_reset, bool initially_signaled);
~Event();

View File

@ -165,6 +165,8 @@ class DelayedMessage {
class MessageQueue {
public:
static const int kForever = -1;
explicit MessageQueue(SocketServer* ss = NULL);
virtual ~MessageQueue();

View File

@ -34,7 +34,7 @@ TEST_F(NullSocketServerTest, WaitAndSet) {
thread.Post(this, 0);
// The process_io will be ignored.
const bool process_io = true;
EXPECT_TRUE_WAIT(ss_.Wait(rtc::kForever, process_io), kTimeout);
EXPECT_TRUE_WAIT(ss_.Wait(SocketServer::kForever, process_io), kTimeout);
}
TEST_F(NullSocketServerTest, TestWait) {

View File

@ -19,7 +19,7 @@ SharedExclusiveLock::SharedExclusiveLock()
void SharedExclusiveLock::LockExclusive() {
cs_exclusive_.Enter();
shared_count_is_zero_.Wait(rtc::kForever);
shared_count_is_zero_.Wait(Event::kForever);
}
void SharedExclusiveLock::UnlockExclusive() {

View File

@ -24,6 +24,8 @@ class MessageQueue;
// notified of asynchronous I/O from this server's Wait method.
class SocketServer : public SocketFactory {
public:
static const int kForever = -1;
// When the socket server is installed into a Thread, this function is
// called to allow the socket server to use the thread's message queue for
// any messaging that it might need to perform.

View File

@ -33,6 +33,8 @@ class Thread;
class ThreadManager {
public:
static const int kForever = -1;
ThreadManager();
~ThreadManager();

View File

@ -594,7 +594,7 @@ bool VirtualSocketServer::ProcessMessagesUntilIdle() {
stop_on_idle_ = true;
while (!msg_queue_->empty()) {
Message msg;
if (msg_queue_->Get(&msg, kForever)) {
if (msg_queue_->Get(&msg, Thread::kForever)) {
msg_queue_->Dispatch(&msg);
}
}

View File

@ -82,10 +82,6 @@ typedef int socklen_t;
namespace rtc {
template<class T> inline T _min(T a, T b) { return (a > b) ? b : a; }
template<class T> inline T _max(T a, T b) { return (a < b) ? b : a; }
// For wait functions that take a number of milliseconds, kForever indicates
// unlimited time.
const int kForever = -1;
}
#if defined(WEBRTC_WIN)