webrtc_m130/webrtc/video_engine/vie_shared_data.cc
tommi@webrtc.org 0c3e12b7bf Revamp the ProcessThreadImpl implementation.
* Add a new WakeUp method that gives a module a chance to be called back right away on the worker thread.
* Wrote unit tests for the class.
* Significantly reduce the amount of locking.
  - ProcessThreadImpl itself does a lot less locking.
  - Reimplemented the way we keep track of when to make calls to Process.
    This reduces the amount of calls to TimeUntilNextProcess and since most implementations of that function grab a lock, this means less locking.
* Renamed ProcessThread::CreateProcessThread to ProcessThread::Create.
* Added thread checks for Start/Stop.  Threading model of other functions is now documented.
* We now log an error if an implementation of TimeUntilNextProcess returns a negative value (some implementations do, but the method should only return a positive nr of ms).
* Removed the DestroyProcessThread method and instead force callers to use scoped_ptr<> to maintain object lifetime.

BUG=2822
R=henrika@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#8261}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8261 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-06 09:44:45 +00:00

60 lines
1.9 KiB
C++

/*
* Copyright (c) 2012 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.
*/
#include "webrtc/modules/utility/interface/process_thread.h"
#include "webrtc/system_wrappers/interface/cpu_info.h"
#include "webrtc/system_wrappers/interface/trace.h"
#include "webrtc/video_engine/vie_channel_manager.h"
#include "webrtc/video_engine/vie_defines.h"
#include "webrtc/video_engine/vie_input_manager.h"
#include "webrtc/video_engine/vie_render_manager.h"
#include "webrtc/video_engine/vie_shared_data.h"
namespace webrtc {
ViESharedData::ViESharedData(const Config& config)
: number_cores_(CpuInfo::DetectNumberOfCores()),
channel_manager_(new ViEChannelManager(0, number_cores_, config)),
input_manager_(new ViEInputManager(0, config)),
render_manager_(new ViERenderManager(0)),
module_process_thread_(ProcessThread::Create()),
last_error_(0) {
Trace::CreateTrace();
channel_manager_->SetModuleProcessThread(module_process_thread_.get());
input_manager_->SetModuleProcessThread(module_process_thread_.get());
module_process_thread_->Start();
}
ViESharedData::~ViESharedData() {
// Release these ones before the process thread and the trace.
input_manager_.reset();
channel_manager_.reset();
render_manager_.reset();
module_process_thread_->Stop();
Trace::ReturnTrace();
}
void ViESharedData::SetLastError(const int error) const {
last_error_ = error;
}
int ViESharedData::LastErrorInternal() const {
int error = last_error_;
last_error_ = 0;
return error;
}
int ViESharedData::NumberOfCores() const {
return number_cores_;
}
} // namespace webrtc