2011-07-07 08:21:25 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_MODULES_UTILITY_SOURCE_PROCESS_THREAD_IMPL_H_
|
|
|
|
|
#define WEBRTC_MODULES_UTILITY_SOURCE_PROCESS_THREAD_IMPL_H_
|
|
|
|
|
|
2014-01-13 15:21:30 +00:00
|
|
|
#include <list>
|
|
|
|
|
|
2015-02-06 09:44:12 +00:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
|
|
|
|
#include "webrtc/base/thread_checker.h"
|
2013-07-12 08:28:10 +00:00
|
|
|
#include "webrtc/modules/utility/interface/process_thread.h"
|
|
|
|
|
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
|
|
|
|
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
|
|
|
|
#include "webrtc/typedefs.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2015-02-06 09:44:12 +00:00
|
|
|
class ProcessThreadImpl : public ProcessThread {
|
|
|
|
|
public:
|
|
|
|
|
ProcessThreadImpl();
|
|
|
|
|
~ProcessThreadImpl() override;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-02-06 09:44:12 +00:00
|
|
|
int32_t Start() override;
|
|
|
|
|
int32_t Stop() override;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-02-06 09:44:12 +00:00
|
|
|
void WakeUp(Module* module) override;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-02-06 09:44:12 +00:00
|
|
|
int32_t RegisterModule(Module* module);
|
|
|
|
|
int32_t DeRegisterModule(const Module* module);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-02-06 09:44:12 +00:00
|
|
|
protected:
|
|
|
|
|
static bool Run(void* obj);
|
|
|
|
|
bool Process();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
rtc::ThreadChecker thread_checker_;
|
|
|
|
|
const rtc::scoped_ptr<EventWrapper> wake_up_;
|
|
|
|
|
rtc::scoped_ptr<ThreadWrapper> thread_;
|
|
|
|
|
|
|
|
|
|
struct ModuleCallback {
|
|
|
|
|
ModuleCallback(Module* module) : module(module), next_callback(0) {}
|
|
|
|
|
bool operator==(const ModuleCallback& cb) const {
|
|
|
|
|
return cb.module == module;
|
|
|
|
|
}
|
|
|
|
|
Module* const module;
|
|
|
|
|
int64_t next_callback; // Absolute timestamp.
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
rtc::CriticalSection lock_; // Used to guard modules_ and stop_.
|
|
|
|
|
typedef std::list<ModuleCallback> ModuleList;
|
|
|
|
|
ModuleList modules_;
|
|
|
|
|
bool stop_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
2015-02-06 09:44:12 +00:00
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
#endif // WEBRTC_MODULES_UTILITY_SOURCE_PROCESS_THREAD_IMPL_H_
|