content/media/webrtc/LoadMonitor.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

michael@0 1 /* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef _LOADMONITOR_H_
michael@0 7 #define _LOADMONITOR_H_
michael@0 8
michael@0 9 #include "mozilla/Mutex.h"
michael@0 10 #include "mozilla/CondVar.h"
michael@0 11 #include "mozilla/RefPtr.h"
michael@0 12 #include "mozilla/Atomics.h"
michael@0 13 #include "nsAutoPtr.h"
michael@0 14 #include "nsCOMPtr.h"
michael@0 15 #include "nsIThread.h"
michael@0 16 #include "nsIObserver.h"
michael@0 17
michael@0 18 namespace mozilla {
michael@0 19 class LoadInfoUpdateRunner;
michael@0 20 class LoadInfoCollectRunner;
michael@0 21
michael@0 22 class LoadNotificationCallback
michael@0 23 {
michael@0 24 public:
michael@0 25 virtual void LoadChanged(float aSystemLoad, float aProcessLoad) = 0;
michael@0 26 };
michael@0 27
michael@0 28 class LoadMonitor MOZ_FINAL : public nsIObserver
michael@0 29 {
michael@0 30 public:
michael@0 31 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 32 NS_DECL_NSIOBSERVER
michael@0 33
michael@0 34 LoadMonitor(int aLoadUpdateInterval);
michael@0 35 ~LoadMonitor();
michael@0 36
michael@0 37 nsresult Init(nsRefPtr<LoadMonitor> &self);
michael@0 38 void SetLoadChangeCallback(LoadNotificationCallback* aCallback);
michael@0 39 void Shutdown();
michael@0 40 float GetSystemLoad();
michael@0 41 float GetProcessLoad();
michael@0 42
michael@0 43 friend class LoadInfoCollectRunner;
michael@0 44
michael@0 45 private:
michael@0 46
michael@0 47 void SetProcessLoad(float load);
michael@0 48 void SetSystemLoad(float load);
michael@0 49 void FireCallbacks();
michael@0 50
michael@0 51 int mLoadUpdateInterval;
michael@0 52 mozilla::Mutex mLock;
michael@0 53 mozilla::CondVar mCondVar;
michael@0 54 bool mShutdownPending;
michael@0 55 nsCOMPtr<nsIThread> mLoadInfoThread;
michael@0 56 float mSystemLoad;
michael@0 57 float mProcessLoad;
michael@0 58 LoadNotificationCallback* mLoadNotificationCallback;
michael@0 59 };
michael@0 60
michael@0 61 } //namespace
michael@0 62
michael@0 63 #endif /* _LOADMONITOR_H_ */

mercurial