Another checkpoint of initial cut at thread pool manager for thrift and related concurrency classes.

Added TimerManager -  I can't live without one after all.

Added Util - handy place for common time operations et al.

Initial test code


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664722 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/Makefile b/lib/cpp/Makefile
index 8403d7c..fde4411 100644
--- a/lib/cpp/Makefile
+++ b/lib/cpp/Makefile
@@ -8,11 +8,19 @@
 # Author:
 #   Mark Slee <mcslee@facebook.com>
 
-target: libthrift
+target: libthrift.so libconcurrency.so
 
 # Tools
 LD    = g++
-LDFL  = -shared -Wall -Isrc -fPIC -Wl,-soname=libthrift.so
+CPP   = g++
+
+CC_COMMON_FLAGS  = -g -c -Wall -Isrc -fPIC -fno-common
+
+LD_COMMON_FLAGS=
+
+LD_APP_FLAGS= $(LD_COMMON_FLAGS)
+
+LD_LIB_FLAGS= -dynamiclib $(LD_COMMON_FLAGS)
 
 # Source files
 SRCS  = src/protocol/TBinaryProtocol.cc \
@@ -22,13 +30,61 @@
 	src/transport/TServerSocket.cc \
 	src/server/TSimpleServer.cc
 
-# Linked library
-libthrift:
-	$(LD) -o libthrift.so $(LDFL) $(SRCS)
+# Concurreny Utility Source files
+CONCURRENCY_SRCS  = src/concurrency/Monitor.cc \
+	            src/concurrency/Mutex.cc \
+	            src/concurrency/PosixThreadFactory.cc \
+	            src/concurrency/ThreadManager.cc \
+	            src/concurrency/TimerManager.cc
+
+CONCURRENCY_OBJS  = $(patsubst %.cc,%.o,$(CONCURRENCY_SRCS))
+
+$(CONCURRENCY_OBJS): %.o : %.cc
+	$(CC) $(CC_COMMON_FLAGS) $< -o $@
+
+CONCURRENCY_TEST_SRCS  = src/concurrency/test/TimerManagerTests.cc
+
+CONCURRENCY_TEST_OBJS  = $(patsubst %.cc,%.o,$(CONCURRENCY_TEST_SRCS))
+
+$(CONCURRENCY_TEST_OBJS): %.o : %.cc
+	$(CC) $(CC_COMMON_FLAGS) -I src/concurrency $< -o $@
+
+# Linked libraries
+
+# thrift library
+
+THRIFT_OBJS  = $(patsubst %.cc,%.o, $(SRCS))
+
+$(THRIFT_OBJS): %.o : %.cc
+	$(CC) $(CC_COMMON_FLAGS) $< -o $@
+
+libthrift.so: $(THRIFT_OBJS)
+	 $(LD) -o $@ $(LD_LIB_FLAGS) $(THRIFT_OBJS)
+
+# concurrency util library
+
+libconcurrency.so: $(CONCURRENCY_OBJS)
+	$(LD) -o $@ $(LD_LIB_FLAGS) $(CONCURRENCY_OBJS)
+
+concurrency_tests: libconcurrency.so $(CONCURRENCY_TEST_OBJS)
+	$(LD) -o $@ $(LD_APP_FLAGS) -L. $(CONCURRENCY_TEST_OBJS)  libconcurrency.so
+
+tests: concurrency_tests
+
+clean_libthrift:
+	rm -f libthrift.so
+	rm -f $(THRIFT_OBJS)
+
+clean_libconcurrency:
+	rm -f libconcurrency.so
+	rm -f $(CONCURRENCY_OBJS)
+
+clean_tests:
+	rm -f concurrency_tests
+	rm -f $(CONCURRENTY_TEST_OBJS)
 
 # Clean it up
-clean:
-	rm -f libthrift.so
+clean: clean_libthrift clean_libconcurrency clean_tests
 
 # Install
 install: libthrift