2011-09-02 09:47:28 +00:00
|
|
|
/*
|
2012-01-24 17:16:59 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-09-02 09:47:28 +00:00
|
|
|
*
|
|
|
|
|
* 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 MODULES_INTERFACE_MODULE_H_
|
|
|
|
|
#define MODULES_INTERFACE_MODULE_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-11-11 10:20:27 +00:00
|
|
|
#include "webrtc/typedefs.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-09-02 09:47:28 +00:00
|
|
|
namespace webrtc {
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-09-02 09:47:28 +00:00
|
|
|
class Module {
|
|
|
|
|
public:
|
2015-01-29 12:12:49 +00:00
|
|
|
// Returns the number of milliseconds until the module wants a worker
|
2011-09-02 09:47:28 +00:00
|
|
|
// thread to call Process.
|
2015-01-29 12:12:49 +00:00
|
|
|
// This method is called on the same worker thread as Process will
|
|
|
|
|
// be called on.
|
2014-12-15 22:09:40 +00:00
|
|
|
virtual int64_t TimeUntilNextProcess() = 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-09-02 09:47:28 +00:00
|
|
|
// Process any pending tasks such as timeouts.
|
2015-01-29 12:12:49 +00:00
|
|
|
// Called on a worker thread.
|
2011-09-02 09:47:28 +00:00
|
|
|
virtual int32_t Process() = 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-09-02 09:47:28 +00:00
|
|
|
protected:
|
|
|
|
|
virtual ~Module() {}
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2015-01-29 12:12:49 +00:00
|
|
|
// Reference counted version of the Module interface.
|
2011-09-02 09:47:28 +00:00
|
|
|
class RefCountedModule : public Module {
|
|
|
|
|
public:
|
|
|
|
|
// Increase the reference count by one.
|
|
|
|
|
// Returns the incremented reference count.
|
2015-01-29 12:12:49 +00:00
|
|
|
virtual int32_t AddRef() = 0;
|
2011-09-02 09:47:28 +00:00
|
|
|
|
|
|
|
|
// Decrease the reference count by one.
|
|
|
|
|
// Returns the decreased reference count.
|
|
|
|
|
// Returns 0 if the last reference was just released.
|
2015-01-29 12:12:49 +00:00
|
|
|
// When the reference count reaches 0 the object will self-destruct.
|
|
|
|
|
virtual int32_t Release() = 0;
|
2011-09-02 09:47:28 +00:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual ~RefCountedModule() {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-09-02 09:47:28 +00:00
|
|
|
#endif // MODULES_INTERFACE_MODULE_H_
|