[Swift-commit] cog r3856

swift at ci.uchicago.edu swift at ci.uchicago.edu
Fri Jan 17 16:25:03 CST 2014


------------------------------------------------------------------------
r3856 | jmwozniak | 2014-01-17 16:22:46 -0600 (Fri, 17 Jan 2014) | 2 lines

Fine-grained logging in class Lock

------------------------------------------------------------------------
Index: modules/provider-coaster-c-client/src/Lock.cpp
===================================================================
--- modules/provider-coaster-c-client/src/Lock.cpp	(revision 3855)
+++ modules/provider-coaster-c-client/src/Lock.cpp	(working copy)
@@ -5,20 +5,39 @@
  *      Author: mike
  */
 
+#include <stdio.h>
+
 #include "Lock.h"
 
+static int unique = 0;
+
+#define DEBUG_LOCKS 1
+#if DEBUG_LOCKS == 1
+#define debug(format, args...)           \
+  {    printf("LOCK: " format "\n", ## args); \
+       fflush(stdout);                   \
+  }
+#else
+#define debug(...) 0;
+#endif
+
 Lock::Lock() {
+  id = unique++;
+	debug("LOCK: %i NEW");
 	pthread_mutex_init(&l, NULL);
 }
 
 Lock::~Lock() {
+	debug("LOCK: %i DELETED");
 }
 
 void Lock::lock() {
+	printf("LOCK: %i ACQUIRE", id);
 	pthread_mutex_lock(&l);
 }
 
 void Lock::unlock() {
+	debug("LOCK: %i RELEASE", id);
 	pthread_mutex_unlock(&l);
 }
 
Index: modules/provider-coaster-c-client/src/Lock.h
===================================================================
--- modules/provider-coaster-c-client/src/Lock.h	(revision 3855)
+++ modules/provider-coaster-c-client/src/Lock.h	(working copy)
@@ -11,6 +11,7 @@
 #include <pthread.h>
 
 class Lock {
+	int id;
 	private:
 		pthread_mutex_t l;
 	public:



More information about the Swift-commit mailing list