#ifndef AVIFILE_LOCKER_H
#define AVIFILE_LOCKER_H

#include <pthread.h>

class PthreadMutex;
class PthreadCond;
class Locker;

class PthreadMutex
{
    pthread_mutex_t* m_pMutex;
friend class PthreadCond;
friend class Locker;
public:
    PthreadMutex();
    ~PthreadMutex();
    int Lock();
    int TryLock();
    int Unlock();
};

class PthreadCond
{
    pthread_cond_t* m_pCond;
public:
    PthreadCond();
    ~PthreadCond();
    int Wait(PthreadMutex& m, float waitTime = 0);
    int Broadcast();
};

class Locker
{
    pthread_mutex_t* m_pMutex;
public:
    Locker(PthreadMutex& mutex);
    Locker(pthread_mutex_t* mutex);
    ~Locker();
};

#endif
