Fresco/Prague/include/Prague/Sys Thread.hh,1.20,1.21

Stefan Seefeld <[email protected]>
Newsgroups gmane.comp.video.fresco.cvs
Message-ID <[email protected]>
Update of /cvs/fresco/Fresco/Prague/include/Prague/Sys
In directory purcel:/tmp/cvs-serv4603/include/Prague/Sys

Modified Files:
	Thread.hh 
Log Message:
add rwlocks

Index: Thread.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Prague/include/Prague/Sys/Thread.hh,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- Thread.hh	2 Jun 2002 23:42:22 -0000	1.20
+++ Thread.hh	28 Mar 2003 21:51:00 -0000	1.21
@@ -1,9 +1,9 @@
 /*$Id$
  *
- * This source file is a part of the Berlin Project.
- * Copyright (C) 1999 Stefan Seefeld <[email protected]> 
- * Copyright (C) 2001 Tobias Hunger <[email protected]>
- * http://www.berlin-consortium.org
+ * This source file is a part of the Fresco Project.
+ * Copyright (C) 1999-2003 Stefan Seefeld <[email protected]> 
+ * Copyright (C) 2001 Tobias Hunger <[email protected]>
+ * http://www.fresco.org
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -131,8 +131,6 @@
   Mutex &mutex;
 };
 
-#if 0
-
 class RWLock
 {
 public:
@@ -144,6 +142,7 @@
     pthread_rwlockattr_t impl;
   };
   RWLock() { pthread_rwlock_init(&impl, 0);}
+  RWLock(const Attribute &a) { pthread_rwlock_init(&impl, &a.impl);}
   ~RWLock() { pthread_rwlock_destroy(&impl);}
   void rlock() { pthread_rwlock_rdlock(&impl);}
   void wlock() { pthread_rwlock_wrlock(&impl);}
@@ -153,31 +152,18 @@
   pthread_rwlock_t impl;
 };
 
-#else
-
-class RWLock 
+class RLockTrait
 {
 public:
-  RWLock() {}
-  ~RWLock() {}
-  void rlock() {}
-  void wlock() {}
-  void unlock() {}
-  bool tryrlock() { return false;}
-  bool trywlock() { return false;}
-private:
-  Mutex mutex;
-  Semaphore readers;
-  Semaphore writers;
+   static void lock(RWLock &l) { l.rlock();}
+   static void unlock(RWLock &l) { l.unlock();}
 };
 
-#endif
-
-template <> class Lock_Trait<RWLock> 
+class WLockTrait
 {
 public:
-  void lock(RWLock & l) { l.rlock();}
-  void unlock(RWLock & l) { l.unlock();}
+   static void lock(RWLock &l) { l.wlock();}
+   static void unlock(RWLock &l) { l.unlock();}
 };
 
 //. a thread housekeeping class.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.