perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 1 | /* |
pwestin@webrtc.org | f6bb77a | 2012-01-24 17:16:59 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef MODULES_INTERFACE_MODULE_H_ |
| 12 | #define MODULES_INTERFACE_MODULE_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
pbos@webrtc.org | 57eb858 | 2013-11-11 10:20:27 +0000 | [diff] [blame] | 14 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 15 | |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 16 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 17 | |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 18 | class Module { |
| 19 | public: |
tommi@webrtc.org | 4161715 | 2015-01-29 12:12:49 +0000 | [diff] [blame] | 20 | // Returns the number of milliseconds until the module wants a worker |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 21 | // thread to call Process. |
tommi@webrtc.org | 4161715 | 2015-01-29 12:12:49 +0000 | [diff] [blame] | 22 | // This method is called on the same worker thread as Process will |
| 23 | // be called on. |
pkasting@chromium.org | 0b1534c | 2014-12-15 22:09:40 +0000 | [diff] [blame] | 24 | virtual int64_t TimeUntilNextProcess() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 26 | // Process any pending tasks such as timeouts. |
tommi@webrtc.org | 4161715 | 2015-01-29 12:12:49 +0000 | [diff] [blame] | 27 | // Called on a worker thread. |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 28 | virtual int32_t Process() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 30 | protected: |
| 31 | virtual ~Module() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | }; |
| 33 | |
tommi@webrtc.org | 4161715 | 2015-01-29 12:12:49 +0000 | [diff] [blame] | 34 | // Reference counted version of the Module interface. |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 35 | class RefCountedModule : public Module { |
| 36 | public: |
| 37 | // Increase the reference count by one. |
| 38 | // Returns the incremented reference count. |
tommi@webrtc.org | 4161715 | 2015-01-29 12:12:49 +0000 | [diff] [blame] | 39 | virtual int32_t AddRef() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 40 | |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 41 | // Decrease the reference count by one. |
| 42 | // Returns the decreased reference count. |
| 43 | // Returns 0 if the last reference was just released. |
tommi@webrtc.org | 4161715 | 2015-01-29 12:12:49 +0000 | [diff] [blame] | 44 | // When the reference count reaches 0 the object will self-destruct. |
| 45 | virtual int32_t Release() = 0; |
perkj@google.com | ef04cf4 | 2011-09-02 09:47:28 +0000 | [diff] [blame] | 46 | |
| 47 | protected: |
| 48 | virtual ~RefCountedModule() {} |
| 49 | }; |
| 50 | |
| 51 | } // namespace webrtc |
| 52 | |
| 53 | #endif // MODULES_INTERFACE_MODULE_H_ |