/usr/include/avifile-0.7/avm_locker.h is in libavifile-0.7-dev 1:0.7.48~20090503.ds-18.
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 | #ifndef AVM_LOCKER_H
#define AVM_LOCKER_H
#include "avm_default.h"
AVM_BEGIN_NAMESPACE;
// do not include pthread.h nor semaphore.h here
// hidden in the implementation
class PthreadMutex;
/**
*
*/
class AVMEXPORT PthreadCond
{
void* m_pCond;
/// \internal disabled
PthreadCond(const PthreadCond&) : m_pCond(0) {}
/// \internal disabled
PthreadCond& operator=(const PthreadCond&) { return *this; }
public:
PthreadCond();
~PthreadCond();
int Wait(PthreadMutex& m, float waitTime = -1.f);
int Broadcast();
};
/**
* class used to hide usage of thread
*
* it might be implemented diferently for various platforms
*/
class AVMEXPORT PthreadMutex
{
void* m_pMutex;
friend int PthreadCond::Wait(PthreadMutex&, float);
/// \internal disabled
PthreadMutex(const PthreadMutex&) : m_pMutex(0) {}
/// \internal disabled
PthreadMutex& operator=(const PthreadMutex&) { return *this; }
public:
// most probably unportable
// enum Attr { FAST, RECURSIVE };
PthreadMutex( /* Attr = FAST */ );
~PthreadMutex();
/// Lock mutex
int Lock();
/// TryLock mutex
int TryLock();
/// Unlock mutex
int Unlock();
};
/**
* Creates a new thread of control that executes concurrently with
* the calling thread.
*/
class AVMEXPORT PthreadTask
{
void* m_pTask;
/// \internal disabled
PthreadTask(const PthreadTask&) : m_pTask(0) {}
/// \internal disabled
PthreadTask& operator=(const PthreadTask&) { return *this; }
public:
PthreadTask(void* attr, void* (*start_routine)(void *), void* arg);
~PthreadTask();
};
/**
* Simple mutex locker for simplifying Lock/Unlock usage
*
* thus there is no need to worry about unlocking on the exit path
* the beauty of C++ :)
*
* constructor locks passed mutex
* destructor unlocks passd mutex
*/
class AVMEXPORT Locker
{
PthreadMutex& m_Mutex;
/// \internal disabled
Locker(const Locker&) : m_Mutex(*(new PthreadMutex())) {}
/// \internal disabled
Locker& operator=(const Locker&) { return *this; }
public:
Locker(PthreadMutex& mutex) : m_Mutex(mutex) { m_Mutex.Lock(); }
~Locker() { m_Mutex.Unlock(); }
};
AVM_END_NAMESPACE;
#ifdef AVM_COMPATIBLE
typedef avm::Locker Locker;
typedef avm::PthreadCond PthreadCond;
typedef avm::PthreadMutex PthreadMutex;
#endif
#endif // AVM_LOCKER_H
|