From: Dejan L. <le...@us...> - 2004-06-07 18:01:56
|
Update of /cvsroot/rtk/rtk/rtk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6007 Modified Files: IO.h Log Message: Lock(), Unloc(), SetMutex() and GetMutex() methods added, as well as private _mutex member. Index: IO.h =================================================================== RCS file: /cvsroot/rtk/rtk/rtk/IO.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IO.h 22 Feb 2004 10:21:29 -0000 1.3 --- IO.h 7 Jun 2004 18:01:34 -0000 1.4 *************** *** 32,37 **** ***** * Authors (chronological order): ! * Mikko Lahteenmaki, mikko§rtk.cx ! * Dejan Lekic, dejan§rtk.cx * Contributors (chronological order): * $fname $lname, $email --- 32,37 ---- ***** * Authors (chronological order): ! * Mikko Lahteenmaki, mikkortk.cx ! * Dejan Lekic, dejanrtk.cx * Contributors (chronological order): * $fname $lname, $email *************** *** 45,48 **** --- 45,49 ---- #include "rtkdef.h" + #include <rtk/Mutex.h> namespace Rtk *************** *** 112,123 **** /** Flushes the buffer. Return -1 on error */ virtual bool Flush() { return 0; } protected: ! IO() : _flags(0) { } /** Set access flags. */ void flags(uint f) { _flags = f; } uint _flags; }; // IO class --- 113,139 ---- /** Flushes the buffer. Return -1 on error */ virtual bool Flush() { return 0; } + + /** Sets Mutex object for IO */ + void SetMutex(const Mutex& arg_mutex) { _mutex = arg_mutex; } + + /** Gets Mutex object from IO */ + Mutex* GetMutex() const { return _mutex; } protected: ! IO() : _flags(0), _mutex(0) { } /** Set access flags. */ void flags(uint f) { _flags = f; } + + /** Locks Mutex (if set) */ + void Lock() { if (_mutex) _mutex->Lock(); } + /** Unlocks Mutex (if set) */ + void Unlock() { if (_mutex) _mutex->Unlock(); } + uint _flags; + + private: + Mutex* _mutex; /// Mutex - by default not set }; // IO class |