r3212 - in trunk/libmutil: . include include/libmutil source

mikma at minisip.org mikma at minisip.org
Sun Feb 18 17:24:57 CET 2007


Author: mikma
Date: 2007-02-18 17:24:56 +0100 (Sun, 18 Feb 2007)
New Revision: 3212

Added:
   trunk/libmutil/include/libmutil/CriticalSection.h
   trunk/libmutil/source/CriticalSection.cxx
Modified:
   trunk/libmutil/Makefile.am
   trunk/libmutil/include/Makefile.am
Log:
Implement CriticalSection. Which locks a mutex in its constructor,
and automatic unlocks the mutex when it goes out of scope.


Modified: trunk/libmutil/Makefile.am
===================================================================
--- trunk/libmutil/Makefile.am	2007-02-18 16:18:24 UTC (rev 3211)
+++ trunk/libmutil/Makefile.am	2007-02-18 16:24:56 UTC (rev 3212)
@@ -44,6 +44,7 @@
 endif !OS_WIN
 
 mutil_src = \
+		source/CriticalSection.cxx \
 		source/MemObject.cxx \
 		source/Library.cxx \
 		source/MessageRouter.cxx \

Modified: trunk/libmutil/include/Makefile.am
===================================================================
--- trunk/libmutil/include/Makefile.am	2007-02-18 16:18:24 UTC (rev 3211)
+++ trunk/libmutil/include/Makefile.am	2007-02-18 16:24:56 UTC (rev 3212)
@@ -1,4 +1,5 @@
 pkginclude_HEADERS = \
+			libmutil/CriticalSection.h \
 			libmutil/Exception.h \
 			libmutil/MessageRouter.h \
 			libmutil/massert.h \

Added: trunk/libmutil/include/libmutil/CriticalSection.h
===================================================================
--- trunk/libmutil/include/libmutil/CriticalSection.h	2007-02-18 16:18:24 UTC (rev 3211)
+++ trunk/libmutil/include/libmutil/CriticalSection.h	2007-02-18 16:24:56 UTC (rev 3212)
@@ -0,0 +1,39 @@
+/*
+  Copyright (C) 2007 Mikael Magnusson
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+/*
+ * Authors: Mikael Magnusson <mikma at users.sourceforge.net>
+*/
+
+
+#ifndef LIBMUTIL_CRITICAL_SECTION_H
+#define LIBMUTIL_CRITICAL_SECTION_H
+
+#include <libmutil/libmutil_config.h>
+#include <libmutil/Mutex.h>
+
+class LIBMUTIL_API CriticalSection{
+	public:
+		CriticalSection(Mutex &mutex);
+		~CriticalSection();
+
+	private:
+		Mutex &mutex;
+};
+
+#endif


Property changes on: trunk/libmutil/include/libmutil/CriticalSection.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: trunk/libmutil/source/CriticalSection.cxx
===================================================================
--- trunk/libmutil/source/CriticalSection.cxx	2007-02-18 16:18:24 UTC (rev 3211)
+++ trunk/libmutil/source/CriticalSection.cxx	2007-02-18 16:24:56 UTC (rev 3212)
@@ -0,0 +1,38 @@
+/*
+  Copyright (C) 2007 Mikael Magnusson
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+/*
+ * Authors: Mikael Magnusson <mikma at users.sourceforge.net>
+*/
+
+
+#include <config.h>
+#include <libmutil/CriticalSection.h>
+
+using namespace std;
+
+CriticalSection::CriticalSection(Mutex &theMutex)
+		:mutex( theMutex )
+{
+	mutex.lock();
+}
+
+CriticalSection::~CriticalSection()
+{
+	mutex.unlock();
+}


Property changes on: trunk/libmutil/source/CriticalSection.cxx
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native



More information about the Minisip-devel mailing list