LCOV - code coverage report
Current view: directory - src/trusted/debug_stub - event_common.cc (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 24 0 0.0 %
Date: 2012-02-16 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright (c) 2011 The Native Client Authors. All rights reserved.
       3                 :  * Use of this source code is governed by a BSD-style license that can be
       4                 :  * found in the LICENSE file.
       5                 :  */
       6                 : 
       7                 : #include "native_client/src/shared/platform/nacl_sync_checked.h"
       8                 : 
       9                 : /*
      10                 :  * Define the common gdb_utils IEvent interface to use the NaCl version.
      11                 :  * IEvent only suports single trigger Signal API.
      12                 :  */
      13                 : 
      14                 : #include "native_client/src/trusted/port/event.h"
      15                 : 
      16                 : namespace port {
      17                 : 
      18                 : class Event : public IEvent {
      19                 :  public:
      20               0 :   Event() : signaled_(false) {
      21               0 :     NaClXMutexCtor(&mutex_);
      22               0 :     NaClXCondVarCtor(&cond_);
      23               0 :   }
      24               0 :   ~Event() {
      25               0 :     NaClCondVarDtor(&cond_);
      26               0 :     NaClMutexDtor(&mutex_);
      27               0 :   }
      28                 : 
      29               0 :   void Wait() {
      30                 :     /* Start the wait owning the lock */
      31               0 :     NaClXMutexLock(&mutex_);
      32                 : 
      33                 :     /* We can skip this if already signaled */
      34               0 :     while (!signaled_) {
      35                 :       /* Otherwise, try and wait, which release the lock */
      36               0 :       NaClXCondVarWait(&cond_, &mutex_);
      37                 : 
      38                 :       /* We exit the wait owning the lock again. */
      39                 :     };
      40                 : 
      41                 :     /* Clear the signal then unlock. */
      42               0 :     signaled_ = false;
      43               0 :     NaClXMutexUnlock(&mutex_);
      44               0 :   }
      45                 : 
      46               0 :   void Signal() {
      47               0 :     signaled_ = true;
      48               0 :     NaClXCondVarSignal(&cond_);
      49               0 :   }
      50                 : 
      51                 :  public:
      52                 :   volatile bool signaled_;
      53                 :   NaClMutex mutex_;
      54                 :   NaClCondVar cond_;
      55                 : };
      56                 : 
      57               0 : IEvent* IEvent::Allocate() {
      58               0 :   return new Event;
      59                 : }
      60                 : 
      61               0 : void IEvent::Free(IEvent *ievent) {
      62               0 :   delete static_cast<Event*>(ievent);
      63               0 : }
      64                 : 
      65                 : }  // End of port namespace

Generated by: LCOV version 1.7