#ifndef INCLUDED_BOBCAT_SHAREDMUTEX_
#define INCLUDED_BOBCAT_SHAREDMUTEX_

#include <pthread.h>

#include <bobcat/exception>

namespace FBB
{

class SharedMutex
{
    pthread_mutex_t d_mutex;

    public:
        SharedMutex();
        SharedMutex(SharedMutex const &other) = delete;

        ~SharedMutex();                 // does unlock

        SharedMutex &operator=(SharedMutex const &rhs) = delete;

        void lock();
        void unlock();

    protected:
        pthread_mutex_t *mutexPtr();
};

inline void SharedMutex::unlock()
{
    pthread_mutex_unlock(&d_mutex);
}
inline pthread_mutex_t *SharedMutex::mutexPtr()
{
    return &d_mutex;
}

} // FBB
#endif
