/usr/include/vtk-6.1/vtkConditionVariable.h is in libvtk6-dev 6.1.0+dfsg2-6.
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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkConditionVariable.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkConditionVariable - mutual exclusion locking class
// .SECTION Description
// vtkConditionVariable allows the locking of variables which are accessed
// through different threads. This header file also defines
// vtkSimpleConditionVariable which is not a subclass of vtkObject.
//
// The win32 implementation is based on notes provided by
// Douglas C. Schmidt and Irfan Pyarali,
// Department of Computer Science,
// Washington University, St. Louis, Missouri.
// http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
#ifndef __vtkConditionVariable_h
#define __vtkConditionVariable_h
#include "vtkCommonCoreModule.h" // For export macro
#include "vtkObject.h"
#include "vtkMutexLock.h" // Need for friend access to vtkSimpleMutexLock
//BTX
#if defined(VTK_USE_PTHREADS) || defined(VTK_HP_PTHREADS)
# include <pthread.h> // Need POSIX thread implementation of mutex (even win32 provides mutexes)
typedef pthread_cond_t vtkConditionType;
#endif
// Typically a top level windows application sets _WIN32_WINNT. If it is not set we set it to
// 0x0501 (Windows XP)
#ifdef VTK_USE_WIN32_THREADS
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0501 // 0x0501 means target Windows XP or later
# endif
# include "vtkWindows.h" // Needed for win32 CRITICAL_SECTION, HANDLE, etc.
#endif
#ifdef VTK_USE_WIN32_THREADS
#if 1
typedef struct
{
// Number of threads waiting on condition.
int WaitingThreadCount;
// Lock for WaitingThreadCount
CRITICAL_SECTION WaitingThreadCountCritSec;
// Semaphore to block threads waiting for the condition to change.
vtkWindowsHANDLE Semaphore;
// An event used to wake up thread(s) waiting on the semaphore
// when pthread_cond_signal or pthread_cond_broadcast is called.
vtkWindowsHANDLE DoneWaiting;
// Was pthread_cond_broadcast called?
size_t WasBroadcast;
} pthread_cond_t;
typedef pthread_cond_t vtkConditionType;
# else // 0
typedef struct
{
// Number of threads waiting on condition.
int WaitingThreadCount;
// Lock for WaitingThreadCount
CRITICAL_SECTION WaitingThreadCountCritSec;
// Number of threads to release when pthread_cond_broadcast()
// or pthread_cond_signal() is called.
int ReleaseCount;
// Used to prevent one thread from decrementing ReleaseCount all
// by itself instead of letting others respond.
int NotifyCount;
// A manual-reset event that's used to block and release waiting threads.
vtkWindowsHANDLE Event;
} pthread_cond_t;
typedef pthread_cond_t vtkConditionType;
# endif // 0
#endif // VTK_USE_WIN32_THREADS
#ifndef VTK_USE_PTHREADS
#ifndef VTK_HP_PTHREADS
#ifndef VTK_USE_WIN32_THREADS
typedef int vtkConditionType;
#endif
#endif
#endif
// Condition variable that is not a vtkObject.
class VTKCOMMONCORE_EXPORT vtkSimpleConditionVariable
{
public:
vtkSimpleConditionVariable();
~vtkSimpleConditionVariable();
static vtkSimpleConditionVariable* New();
void Delete() { delete this; }
// Description:
// Wake one thread waiting for the condition to change.
void Signal();
// Description:
// Wake all threads waiting for the condition to change.
void Broadcast();
// Description:
// Wait for the condition to change.
// Upon entry, the mutex must be locked and the lock held by the calling thread.
// Upon exit, the mutex will be locked and held by the calling thread.
// Between entry and exit, the mutex will be unlocked and may be held by other threads.
//
// @param mutex The mutex that should be locked on entry and will be locked on exit (but not in between)
// @retval Normally, this function returns 0. Should a thread be interrupted by a signal, a non-zero value may be returned.
int Wait( vtkSimpleMutexLock& mutex );
protected:
vtkConditionType ConditionVariable;
private:
vtkSimpleConditionVariable(const vtkSimpleConditionVariable& other); // no copy constructor
vtkSimpleConditionVariable& operator=(const vtkSimpleConditionVariable& rhs); // no copy assignment
};
//ETX
class VTKCOMMONCORE_EXPORT vtkConditionVariable : public vtkObject
{
public:
static vtkConditionVariable* New();
vtkTypeMacro(vtkConditionVariable,vtkObject);
void PrintSelf( ostream& os, vtkIndent indent );
// Description:
// Wake one thread waiting for the condition to change.
void Signal();
// Description:
// Wake all threads waiting for the condition to change.
void Broadcast();
// Description:
// Wait for the condition to change.
// Upon entry, the mutex must be locked and the lock held by the calling thread.
// Upon exit, the mutex will be locked and held by the calling thread.
// Between entry and exit, the mutex will be unlocked and may be held by other threads.
//
// @param mutex The mutex that should be locked on entry and will be locked on exit (but not in between)
// @retval Normally, this function returns 0. Should a thread be interrupted by a signal, a non-zero value may be returned.
int Wait( vtkMutexLock* mutex );
protected:
vtkConditionVariable() { }
//BTX
vtkSimpleConditionVariable SimpleConditionVariable;
//ETX
private:
vtkConditionVariable( const vtkConditionVariable& ); // Not implemented.
void operator = ( const vtkConditionVariable& ); // Not implemented.
};
//BTX
inline void vtkConditionVariable::Signal()
{
this->SimpleConditionVariable.Signal();
}
inline void vtkConditionVariable::Broadcast()
{
this->SimpleConditionVariable.Broadcast();
}
inline int vtkConditionVariable::Wait( vtkMutexLock* lock )
{
return this->SimpleConditionVariable.Wait( lock->SimpleMutexLock );
}
//ETX
#endif // __vtkConditionVariable_h
|