Класс для синхронизации потоков. Подробнее...
#include <system/mutex_abstraction.h>
Открытые члены | |
| MutexAbstraction (void) | |
| void | Release (void) |
| void | CreateMutex (void) |
| void | Lock (void) |
| void | UnLock (void) |
| virtual | ~MutexAbstraction () |
Закрытые члены | |
| MutexAbstraction (const MutexAbstraction &m) | |
| MutexAbstraction | operator= (const MutexAbstraction &m) |
Закрытые данные | |
| void * | Mutex |
Класс для синхронизации потоков.
См. определение в файле mutex_abstraction.h строка 45
| nitro::MutexAbstraction::MutexAbstraction | ( | void | ) |
Конструктор.
| nitro::exception | - Кидается исключение этого типа с описанием ошибки. |
См. определение в файле mutex_abstraction.cpp строка 21
Перекрестные ссылки nitro::exception::code(), Mutex и nitro::exception::what().
{
try
{
Mutex = NULL;
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "MutexAbstraction::MutexAbstraction( void )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "MutexAbstraction::MutexAbstraction( void )::An error occured" ) , 1 ) );
}
}

| nitro::MutexAbstraction::~MutexAbstraction | ( | ) | [virtual] |
Деструктор.
См. определение в файле mutex_abstraction.cpp строка 37
Перекрестные ссылки Release().
{
try
{
Release();
}
catch( ... )
{
}
}

| nitro::MutexAbstraction::MutexAbstraction | ( | const MutexAbstraction & | m | ) | [private] |
Конструктор копирования.
| m | - Копируемый мьютекс. |
См. определение в файле mutex_abstraction.cpp строка 176
{
}
| void nitro::MutexAbstraction::CreateMutex | ( | void | ) |
Функция создания мьютекса.
| nitro::exception | - Кидается исключение этого типа с описанием ошибки. |
См. определение в файле mutex_abstraction.cpp строка 78
Перекрестные ссылки nitro::exception::code(), Mutex, Release() и nitro::exception::what().
Используется в nitro::LogStream::Reset().
{
try
{
Release();
#if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
Mutex = ( void * )new HANDLE;
char MutexName[ 1024 ];
memset( MutexName , 0 , 1024 );
#if defined( WIN32_PLATFORM )
sprintf( MutexName , "%I64d" , ( __int64 )this );
#endif
#if defined( MINGW_PLATFORM )
sprintf( MutexName , "%ld" , ( __int32 )this );
#endif
* ( ( HANDLE * )Mutex ) = ::CreateMutexA( NULL , false , MutexName );
if( * ( ( HANDLE * )Mutex ) == NULL )
{
throw( nitro::exception( "Mutex was not initialized" , 1 ) );
}
#endif
#if defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
Mutex = ( void * )new pthread_mutex_t;
if( pthread_mutex_init( ( pthread_mutex_t * )Mutex , NULL ) != 0 )
{
throw( nitro::exception( "Mutex was not initialized" , 1 ) );
}
#endif
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "MutexAbstraction::CreateMutex( void )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "MutexAbstraction::CreateMutex( void )::An error occured" ) , 1 ) );
}
}

| void nitro::MutexAbstraction::Lock | ( | void | ) |
Функция блокирования.
| nitro::exception | - Кидается исключение этого типа с описанием ошибки. |
См. определение в файле mutex_abstraction.cpp строка 122
Перекрестные ссылки nitro::exception::code(), Mutex и nitro::exception::what().
Используется в nitro::LogStream::operator<<().
{
try
{
if( Mutex )
{
#if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
WaitForSingleObject( * ( ( HANDLE * )Mutex ) , INFINITE );
#endif
#if defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
std::cout<<"9"<<std::endl;
pthread_mutex_lock( ( pthread_mutex_t * )Mutex );
std::cout<<"10"<<std::endl;
#endif
}
else
{
std::cout<<"8"<<std::endl;
throw( nitro::exception( "Mutex was not initialized" , 1 ) );
}
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "MutexAbstraction::Lock( void )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "MutexAbstraction::Lock( void )::An error occured" ) , 1 ) );
}
}

| MutexAbstraction nitro::MutexAbstraction::operator= | ( | const MutexAbstraction & | m | ) | [private] |
Оператор присваивания.
| m | - копируемый мьютекс. |
См. определение в файле mutex_abstraction.cpp строка 180
{
return( *this );
}
| void nitro::MutexAbstraction::Release | ( | void | ) |
Удаление мьютекса.
| nitro::exception | - Кидается исключение этого типа с описанием ошибки. |
См. определение в файле mutex_abstraction.cpp строка 48
Перекрестные ссылки nitro::exception::code(), Mutex и nitro::exception::what().
Используется в CreateMutex(), nitro::LogStream::Release() и ~MutexAbstraction().
{
try
{
if( Mutex )
{
#if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
CloseHandle( * ( ( HANDLE * )Mutex ) );
delete ( HANDLE * )Mutex;
#endif
#ifdef NIX_PLATFORM
pthread_mutex_destroy( ( pthread_mutex_t * )Mutex );
delete ( pthread_mutex_t * )Mutex;
#endif
Mutex = NULL;
}
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "MutexAbstraction::Release( void )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "MutexAbstraction::Release( void )::An error occured" ) , 1 ) );
}
}

| void nitro::MutexAbstraction::UnLock | ( | void | ) |
Функция разблокирования.
| nitro::exception | - Кидается исключение этого типа с описанием ошибки. |
См. определение в файле mutex_abstraction.cpp строка 154
Перекрестные ссылки nitro::exception::code(), Mutex и nitro::exception::what().
Используется в nitro::LogStream::operator<<().
{
try
{
#if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
ReleaseMutex( * ( ( HANDLE * )Mutex ) );
#endif
#if defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
pthread_mutex_unlock( ( pthread_mutex_t * )Mutex );
#endif
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "MutexAbstraction::UnLock( void )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "MutexAbstraction::UnLock( void )::An error occured" ) , 1 ) );
}
}

void* nitro::MutexAbstraction::Mutex [private] |
Данные мьютекса.
См. определение в файле mutex_abstraction.h строка 152
Используется в CreateMutex(), Lock(), MutexAbstraction(), Release() и UnLock().
1.6.1