niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 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 WEBRTC_SYSTEM_WRAPPERS_SOURCE_CPU_MAC_H_ |
| 12 | #define WEBRTC_SYSTEM_WRAPPERS_SOURCE_CPU_MAC_H_ |
| 13 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 14 | #include "system_wrappers/interface/cpu_wrapper.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 15 | |
| 16 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 17 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 18 | class CpuWrapperMac : public CpuWrapper { |
| 19 | public: |
| 20 | CpuWrapperMac(); |
| 21 | virtual ~CpuWrapperMac(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 23 | virtual WebRtc_Word32 CpuUsage(); |
| 24 | virtual WebRtc_Word32 CpuUsage(WebRtc_Word8* process_name, |
| 25 | WebRtc_UWord32 length) { |
| 26 | return -1; |
| 27 | } |
| 28 | virtual WebRtc_Word32 CpuUsage(WebRtc_UWord32 process_id) { |
| 29 | return -1; |
| 30 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 32 | // Note: this class will block the call and sleep if called too fast |
| 33 | // This function blocks the calling thread if the thread is calling it more |
| 34 | // often than every 500 ms. |
| 35 | virtual WebRtc_Word32 CpuUsageMultiCore(WebRtc_UWord32& num_cores, |
| 36 | WebRtc_UWord32*& array); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 38 | virtual void Reset() {} |
| 39 | virtual void Stop() {} |
| 40 | |
| 41 | private: |
| 42 | WebRtc_Word32 Update(WebRtc_Word64 time_diffMS); |
| 43 | |
| 44 | WebRtc_UWord32 cpu_count_; |
| 45 | WebRtc_UWord32* cpu_usage_; |
| 46 | WebRtc_Word32 total_cpu_usage_; |
| 47 | WebRtc_Word64* last_tick_count_; |
| 48 | WebRtc_Word64 last_time_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 49 | }; |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 50 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 51 | } // namespace webrtc |
| 52 | |
phoglund@webrtc.org | b15d285 | 2012-11-21 08:02:57 +0000 | [diff] [blame] | 53 | #endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CPU_MAC_H_ |