Skip to content

Instantly share code, notes, and snippets.

@adurpas
Created December 3, 2012 14:52
Show Gist options
  • Save adurpas/4195462 to your computer and use it in GitHub Desktop.
Save adurpas/4195462 to your computer and use it in GitHub Desktop.
// ISU laboratory session #8, exercise #1.
#include <iostream>
//#include <osapi/Exceptions>
#include <osapi/Mutex.hpp>
namespace osapi
{
Mutex::Mutex()
{
if(pthread_mutex_init(&mtxID_, NULL))
throw MutexError();
}
Mutex::~Mutex()
{
if(pthread_mutex_destroy(&mtxID_))
throw MutexError();
}
void Mutex::lock()
{
if(pthread_mutex_lock(&mtxID_))
throw MutexError();
}
void Mutex::unlock()
{
if(pthread_mutex_unlock(&mtxID_))
throw MutexError();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment