This file is indexed.

/usr/include/gnelib/ConditionVariable.h is in libgnelib-dev 0.75+svn20091130-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef CONDITIONVARIABLE_H_INCLUDED_C51DFF03
#define CONDITIONVARIABLE_H_INCLUDED_C51DFF03

/* GNE - Game Networking Engine, a portable multithreaded networking library.
 * Copyright (C) 2001-2006 Jason Winnebeck 
 * Project website: http://www.gillius.org/gne/
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */


namespace GNE {
class Mutex;
class Time;

/**
 * @ingroup threading
 *
 * A class for a conditional variable.  This is to be used when a thread needs
 * to wait for a condition that another thread will trigger.  The most common
 * usage of ConditionVariables:
 *
 * <pre>
 * cv.lock();
 * while (!condition) {
 *   cv.wait();
 * }
 * //do stuff
 * cv.unlock();
 * </pre>
 *
 * When cv.wait is called, the thread atomically releases the associated
 * mutex and waits for another thread to call signal or broadcast on the cv
 * object.  When this thread reawakens, it waits to lock the associated mutex
 * then exits the wait call.
 */
class ConditionVariable {
public:
  /**
   * Initalizes this class creating a new mutex.
   */
  ConditionVariable();

  /**
   * Initalizes this class, with another mutex that the caller is
   * responsible for allocating and destroying.
   * @param m the mutex to be associated with this conditional variable.
   *          this mutex will not be deallocated.
   */
  ConditionVariable(Mutex* m);

  virtual ~ConditionVariable();

  /**
   * Locks the associated mutex for this condition variable.
   * @see Mutex#acquire()
   */
  void acquire();

  /**
   * Releases the associated mutex.
   * @see Mutex#release()
   */
  void release();

  /**
   * This method will block until the thread is woken up by a call to
   * signal or broadcast.  The associated mutex must be locked when wait()
   * is called.  wait() will unlock the mutex and block until woken up at
   * which point it will re-acquire the mutex.
   */
  void wait();

  /**
   * This method works identical to wait, except the thread will wake up
   * anyways if not woken up before the timeout.  The mutex will still be
   * reacquired.
   * @param timeout the time to wait in milliseconds
   */
  void timedWait(int ms);

  /**
   * Waits until the given time, specified in absolute time.
   */
  void timedWait(const Time& until);

  /**
   * Wakes up at least one thread waiting on this CV.  Which thread wakes up
   * is implementation dependant.
   */
  void signal();

  /**
   * Wakes up all threads waiting on this CV.
   */
  void broadcast();

private:
  struct ConditionVariableData;
  ConditionVariableData* data;

#ifdef WIN32
  //The Windows implementation of condition variables comes from the Boost
  //C++ library.
  void initBoostCode();
  void enter_wait();
#endif

  /**
   * is the mutex pointer we have our mutex we should delete?
   */
  bool ourMutex;

  /**
   * The mutex associated with this Conditional Variable
   */
  Mutex* mutex;
};

}
#endif /* CONDITIONVARIABLE_H_INCLUDED_C51DFF03 */