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
14#include "cpu_wrapper.h"
15
16namespace webrtc {
17class CpuWrapperMac : public CpuWrapper
18{
19public:
20    CpuWrapperMac();
21    virtual ~CpuWrapperMac();
22
23    virtual WebRtc_Word32 CpuUsage();
24    virtual WebRtc_Word32 CpuUsage(WebRtc_Word8* /*pProcessName*/,
25                                   WebRtc_UWord32 /*length*/) {return -1;}
26    virtual WebRtc_Word32 CpuUsage(WebRtc_UWord32  /*dwProcessID*/) {return -1;}
27
28    // Note: this class will block the call and sleep if called too fast
29    // This function blocks the calling thread if the thread is calling it more
30    // often than every 500 ms.
31    virtual WebRtc_Word32 CpuUsageMultiCore(WebRtc_UWord32& numCores,
32                                            WebRtc_UWord32*& array);
33
34    virtual void Reset() {}
35    virtual void Stop() {}
36
37private:
38    WebRtc_Word32 Update(WebRtc_Word64 timeDiffMS);
39
40    WebRtc_UWord32  _cpuCount;
41    WebRtc_UWord32* _cpuUsage;
42    WebRtc_Word32   _totalCpuUsage;
43    WebRtc_Word64*  _lastTickCount;
44    WebRtc_Word64   _lastTime;
45};
46} // namespace webrtc
47
48#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_CPU_MAC_H_
49