Fresco/Prague/demo/Thread RWLock.cc,NONE,1.1 Makefile.in,1.3,1.4

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

Modified Files:
	Makefile.in 
Added Files:
	RWLock.cc 
Log Message:
add rwlocks

--- NEW FILE: RWLock.cc ---
#include <Prague/Sys/Thread.hh>
#include <Prague/Sys/Tracer.hh>
#include <unistd.h>

using namespace Prague;

RWLock::Attribute attr;
RWLock lock(attr);

void *reader1(void *)
{
   while (true)
   {
      {
         Guard<RWLock, RLockTrait> guard(lock);
         Trace trace("reader 1 reading");
         usleep(500000);
      }
//       usleep(500000);
   }
}

void *reader2(void *)
{
   while (true)
   {
      {
         Guard<RWLock, RLockTrait> guard(lock);
         Trace trace("reader 2 reading");
         usleep(500000);
      }
//       usleep(500000);
   }
}

void *writer(void *)
{
   while (true)
   {
      {
         Guard<RWLock, WLockTrait> guard(lock);
         Trace trace("writer writing");
         usleep(500000);
      }
//       usleep(500000);
   }
}

int main(int, char **)
{
   Tracer::logging(true);
   Thread thread1(reader1, 0);
   Thread thread2(reader2, 0);
   Thread thread3(writer, 0);
   thread1.start();
   thread2.start();
   thread3.start();
   sleep(10);
}

Index: Makefile.in
===================================================================
RCS file: /cvs/fresco/Fresco/Prague/demo/Thread/Makefile.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Makefile.in	19 Feb 2003 18:46:28 -0000	1.3
+++ Makefile.in	28 Mar 2003 21:51:00 -0000	1.4
@@ -29,11 +29,11 @@
 
 include $(cdir)/local.mk
 
-CPPFLAGS	+= @CPPFLAGS@
+CPPFLAGS	+= @CPPFLAGS@ -I $(top_builddir)/include -I $(top_srcdir)
 LDFLAGS		+= -L ../../lib
 LIBS		+= -lPrague @LIBS@
 
-TARGETS		:=   $(patsubst %, $(top_builddir)/bin/%, Thread Signal Timer Diner Queue ThreadPool)
+TARGETS		:=   $(patsubst %, $(top_builddir)/bin/%, Thread RWLock Signal Timer Diner Queue ThreadPool)
 
 vpath %.hh  $(srcdir)
 vpath %.cc  $(srcdir)
@@ -45,6 +45,10 @@
 		$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(OPTFLAGS) -c $< -o $@
 
 $(top_builddir)/bin/Thread:	Thread.o
+		@echo linking $(@F)
+		$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+$(top_builddir)/bin/RWLock:	RWLock.o
 		@echo linking $(@F)
 		$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
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.