LCOV - code coverage report
Current view: top level - gfx/layers/ipc - SynchronousTask.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 20 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef MOZILLA_GFX_SYNCHRONOUSTASK_H
       7             : #define MOZILLA_GFX_SYNCHRONOUSTASK_H
       8             : 
       9             : #include "mozilla/ReentrantMonitor.h"   // for ReentrantMonitor, etc
      10             : 
      11             : namespace mozilla {
      12             : namespace layers {
      13             : 
      14             : // Helper that creates a monitor and a "done" flag, then enters the monitor.
      15             : // This can go away when we switch ImageBridge to an XPCOM thread.
      16           0 : class MOZ_STACK_CLASS SynchronousTask
      17             : {
      18             :   friend class AutoCompleteTask;
      19             : 
      20             : public:
      21           0 :   explicit SynchronousTask(const char* name)
      22           0 :    : mMonitor(name),
      23             :      mAutoEnter(mMonitor),
      24           0 :      mDone(false)
      25           0 :   {}
      26             : 
      27           0 :   void Wait() {
      28           0 :     while (!mDone) {
      29           0 :       mMonitor.Wait();
      30             :     }
      31           0 :   }
      32             : 
      33             : private:
      34           0 :   void Complete() {
      35           0 :     mDone = true;
      36           0 :     mMonitor.NotifyAll();
      37           0 :   }
      38             : 
      39             : private:
      40             :   ReentrantMonitor mMonitor;
      41             :   ReentrantMonitorAutoEnter mAutoEnter;
      42             :   bool mDone;
      43             : };
      44             : 
      45             : class MOZ_STACK_CLASS AutoCompleteTask
      46             : {
      47             : public:
      48           0 :   explicit AutoCompleteTask(SynchronousTask* aTask)
      49           0 :    : mTask(aTask),
      50           0 :      mAutoEnter(aTask->mMonitor)
      51             :   {
      52           0 :   }
      53           0 :   ~AutoCompleteTask() {
      54           0 :     mTask->Complete();
      55           0 :   }
      56             : 
      57             : private:
      58             :   SynchronousTask* mTask;
      59             :   ReentrantMonitorAutoEnter mAutoEnter;
      60             : };
      61             : 
      62             : }
      63             : }
      64             : 
      65             : #endif

Generated by: LCOV version 1.13