00001
00002
00003 #include "debug.h"
00004 #include "locks.h"
00005 #include "filesystem.h"
00006 #include "utils.h"
00007
00008 int lockMutex(mutex_type **mutex) {
00009 char sem_name[1024];
00010 getResourceName(sem_name, SEM_NAME);
00011
00012 *mutex = new boost::interprocess::named_mutex(boost::interprocess::open_or_create, sem_name);
00013 (*mutex)->lock();
00014 return 0;
00015 }
00016 void unlockMutex(mutex_type **mutex) {
00017 (*mutex)->unlock();
00018 delete *mutex;
00019 }
00020
00021
00022 void resetMutex(mutex_type **mutex) {
00023 char sem_name[1024];
00024 getResourceName(sem_name, SEM_NAME);
00025 try {
00026 mutex_type *mutex0 = new boost::interprocess::named_mutex(boost::interprocess::open_only, sem_name);
00027 mutex0->unlock();
00028 delete mutex0;
00029 boost::interprocess::named_mutex::remove(sem_name);
00030 } catch (boost::interprocess::interprocess_exception e) {
00031
00032 }
00033 }
00034
00035