Home » U++ Library support » U++ MT-multithreading and servers » Mutex locks vs copy constructors
Mutex locks vs copy constructors [message #18266] |
Fri, 19 September 2008 15:54  |
cas_
Messages: 20 Registered: July 2008 Location: Poland
|
Promising Member |
|
|
Hi!
I believe that copy constructors of Mutex::Lock, RWMutex::ReadLock and RWMutex::WriteLock should be declared private. Currently, they are public and this fact can easily lead to errors if someone is not careful enough. Core/Mt.h should be changed as follows:
struct Mutex::Lock {
Mutex& s;
Lock(Mutex& s) : s(s) { s.Enter(); }
~Lock() { s.Leave(); }
private:
Lock( const Lock& );
};
struct RWMutex::ReadLock {
RWMutex& s;
ReadLock(RWMutex& s) : s(s) { s.EnterRead(); }
~ReadLock() { s.LeaveRead(); }
private:
ReadLock( const ReadLock& );
};
struct RWMutex::WriteLock {
RWMutex& s;
WriteLock(RWMutex& s) : s(s) { s.EnterWrite(); }
~WriteLock() { s.LeaveWrite(); }
private:
WriteLock( const WriteLock& );
};
|
|
|
|
|
Goto Forum:
Current Time: Tue May 13 20:11:19 CEST 2025
Total time taken to generate the page: 0.02027 seconds
|