![]() |
|
|
Bdb packages | Design docs | Source docs | Guidelines | Recent releases |
|
Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Compound Members File Members /BdbTransfer/BdbPTMutex.h
Go to the documentation of this file.00001 //------------------------------------------------------------------------------ 00002 // File and Version Information: 00003 // $Id: BdbPTMutex.h,v 1.3 1999/07/14 04:14:45 svarovsk Exp $ 00004 // 00005 // Description: 00006 // C++ interface library to POSIX threads 00007 // this is pure interface to system calls 00008 // all functions are inline 00009 // 00010 // this file deals with mutexes 00011 // 00012 // Environment: 00013 // Software developed for the BaBar Detector at the SLAC B-Factory 00014 // 00015 // Author: 00016 // Gennadi S. Svarovski (svarovsk@slac.stanford.edu) 00017 // original author 00018 // 00019 // Copyright Information: 00020 // Copyright (C) 1999 Stanford Linear Accelerator Center 00021 // 00022 //------------------------------------------------------------------------------ 00023 00024 #ifndef _BDBPTMUTEX_H_ 00025 #define _BDBPTMUTEX_H_ 00026 00027 #include <pthread.h> 00028 00029 #include "BdbTransfer/BdbPTMutexAttr.h" 00030 00031 class BdbPTCond; 00032 00033 class BdbPTMutex { 00034 private: 00035 pthread_mutex_t mutex; 00036 00037 public: 00038 // default constructor 00039 inline BdbPTMutex(); 00040 inline BdbPTMutex( const BdbPTMutexAttr &Attr ); 00041 // destructor 00042 inline ~BdbPTMutex(); 00043 00044 // access methods 00045 inline int lock ( void ); 00046 inline int trylock ( void ); 00047 inline int unlock ( void ); 00048 00049 friend class BdbPTCond; 00050 00051 private: 00052 // need to prohibit copying of any kind 00053 inline BdbPTMutex( BdbPTMutex& c ) {}; 00054 inline BdbPTMutex& operator =(BdbPTMutex& c ) { return *this; }; 00055 }; 00056 00057 // default constructor 00058 inline BdbPTMutex::BdbPTMutex() { 00059 pthread_mutex_init( &mutex, NULL ); 00060 } 00061 00062 inline BdbPTMutex::BdbPTMutex( const BdbPTMutexAttr &Attr ) { 00063 pthread_mutex_init( &mutex, &Attr.attr ); 00064 } 00065 00066 // destructor 00067 inline BdbPTMutex::~BdbPTMutex() { 00068 pthread_mutex_destroy( &mutex ); 00069 } 00070 00071 // access methods 00072 inline int BdbPTMutex::lock ( void ) { 00073 return pthread_mutex_lock( &mutex ); 00074 } 00075 00076 inline int BdbPTMutex::trylock ( void ) { 00077 return pthread_mutex_trylock( &mutex ); 00078 } 00079 00080 inline int BdbPTMutex::unlock ( void ) { 00081 return pthread_mutex_unlock( &mutex ); 00082 } 00083 00084 #endif // _BDBPTMUTEX_H_
BaBar Public Site | SLAC | News | Links | Who's Who | Contact Us
Page Owner: Jacek Becla
Last Update: October 04, 2002