From: Christian P. <cp...@us...> - 2005-05-06 15:21:11
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9502/src Added Files: CoreMutex.posix.cpp CoreMutex.win32.cpp Removed Files: AtomicMutex.posix.cpp AtomicMutex.win32.cpp Log Message: - Renamed AtomicMutex to CoreMutex. We need a mutex in the core module for thread-safety. --- NEW FILE: CoreMutex.win32.cpp --- /*************************************************************************** * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "pclasses/CoreMutex.h" #include <windows.h> namespace P { namespace Traits { CoreMutex::CoreMutex() : _handle((unsigned long)new CRITICAL_SECTION) { InitializeCriticalSection((CRITICAL_SECTION*)_handle)); } CoreMutex::~CoreMutex() { DeleteCriticalSection((CRITICAL_SECTION*)_handle)); delete (CRITICAL_SECTION*)_handle; } void CoreMutex::lock() throw() { EnterCriticalSection((CRITICAL_SECTION*)_handle)); } void CoreMutex::unlock() throw() { LeaveCriticalSection((CRITICAL_SECTION*)_handle)); } CoreMutex::ScopedLock::ScopedLock(CoreMutex& mtx) : _mtx(mtx) { _mtx.lock(); } CoreMutex::ScopedLock::~ScopedLock() { _mtx.unlock(); } } // !namespace Traits } // !namespace P --- NEW FILE: CoreMutex.posix.cpp --- /*************************************************************************** * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "pclasses/CoreMutex.h" #include <pthread.h> namespace P { namespace Traits { CoreMutex::CoreMutex() : _handle((unsigned long)new pthread_mutex_t) { pthread_mutex_init((pthread_mutex_t*)_handle, 0); } CoreMutex::~CoreMutex() { pthread_mutex_destroy((pthread_mutex_t*)_handle); delete (pthread_mutex_t*)_handle; } void CoreMutex::lock() throw() { pthread_mutex_lock((pthread_mutex_t*)_handle); } void CoreMutex::unlock() throw() { pthread_mutex_unlock((pthread_mutex_t*)_handle); } CoreMutex::ScopedLock::ScopedLock(CoreMutex& mtx) : _mtx(mtx) { _mtx.lock(); } CoreMutex::ScopedLock::~ScopedLock() { _mtx.unlock(); } } // !namespace Traits } // !namespace P --- AtomicMutex.posix.cpp DELETED --- --- AtomicMutex.win32.cpp DELETED --- |