Открытые члены | Закрытые члены | Закрытые данные

Класс nitro::MutexAbstraction

Класс для синхронизации потоков. Подробнее...

#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]

Деструктор.

Автор:
Dodonov A.A.

См. определение в файле 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 ) );
                }
        }

Граф вызовов:


Данные класса

Данные мьютекса.

Автор:
Додонов А.А.

См. определение в файле mutex_abstraction.h строка 152

Используется в CreateMutex(), Lock(), MutexAbstraction(), Release() и UnLock().


Объявления и описания членов классов находятся в файлах:

Generated by  doxygen 1.6.1