Explorar o código

windows下编译通过,删除game模块,game模块应该用脚本层实现,去除threadpool

tanghai %!s(int64=12) %!d(string=hai) anos
pai
achega
0e6f92cc15
Modificáronse 68 ficheiros con 193 adicións e 3253 borrados
  1. 13 9
      Cpp/CMakeLists.txt
  2. 0 48
      Cpp/Game/BehaviorTree/BehaviorNode.h
  3. 0 54
      Cpp/Game/BehaviorTree/BehaviorTree.cc
  4. 0 34
      Cpp/Game/BehaviorTree/BehaviorTree.h
  5. 0 18
      Cpp/Game/BehaviorTree/BehaviorTreeConf.proto
  6. 0 42
      Cpp/Game/BehaviorTree/BuffType.cc
  7. 0 36
      Cpp/Game/BehaviorTree/BuffType.h
  8. 0 38
      Cpp/Game/BehaviorTree/CMakeLists.txt
  9. 0 50
      Cpp/Game/BehaviorTree/ChangeHealth.cc
  10. 0 33
      Cpp/Game/BehaviorTree/ChangeHealth.h
  11. 0 24
      Cpp/Game/BehaviorTree/CombatContex.cc
  12. 0 26
      Cpp/Game/BehaviorTree/CombatContex.h
  13. 0 20
      Cpp/Game/BehaviorTree/ContexIf.h
  14. 0 36
      Cpp/Game/BehaviorTree/EventDefine.h
  15. 0 42
      Cpp/Game/BehaviorTree/GameEvents.cc
  16. 0 30
      Cpp/Game/BehaviorTree/GameEvents.h
  17. 0 75
      Cpp/Game/BehaviorTree/GameEventsTest.cc
  18. 0 46
      Cpp/Game/BehaviorTree/NodeFactories.cc
  19. 0 24
      Cpp/Game/BehaviorTree/NodeFactories.h
  20. 0 40
      Cpp/Game/BehaviorTree/NotNode.cc
  21. 0 34
      Cpp/Game/BehaviorTree/NotNode.h
  22. 0 54
      Cpp/Game/BehaviorTree/SelectorNode.cc
  23. 0 35
      Cpp/Game/BehaviorTree/SelectorNode.h
  24. 0 54
      Cpp/Game/BehaviorTree/SequenceNode.cc
  25. 0 35
      Cpp/Game/BehaviorTree/SequenceNode.h
  26. 0 33
      Cpp/Game/BehaviorTree/SpellBuff.h
  27. 0 26
      Cpp/Game/BehaviorTree/Vampire.txt
  28. 0 1
      Cpp/Game/CMakeLists.txt
  29. 1 1
      Cpp/Platform/Base/Exception.h
  30. 5 5
      Cpp/Platform/Base/Typedef.h
  31. 1 4
      Cpp/Platform/CMakeLists.txt
  32. 35 42
      Cpp/Platform/Log/Log.cc
  33. 10 9
      Cpp/Platform/Log/Log.h
  34. 4 9
      Cpp/Platform/Log/LogTest.cc
  35. 1 1
      Cpp/Platform/Orm/DbHelper.h
  36. 1 1
      Cpp/Platform/Orm/DbResult.h
  37. 2 2
      Cpp/Platform/Orm/DbResultTest.cc
  38. 10 10
      Cpp/Platform/Orm/MessageFieldTest.cc
  39. 5 5
      Cpp/Platform/Orm/Typedef.h
  40. 1 1
      Cpp/Platform/Python/PythonInterpreter.h
  41. 3 3
      Cpp/Platform/Python/PythonInterpreterTest.cc
  42. 7 6
      Cpp/Platform/Rpc/CMakeLists.txt
  43. 4 3
      Cpp/Platform/Rpc/ResponseHandler.cc
  44. 6 5
      Cpp/Platform/Rpc/RpcClient.cc
  45. 5 6
      Cpp/Platform/Rpc/RpcClientTest.cc
  46. 24 19
      Cpp/Platform/Rpc/RpcCommunicatorTest.cc
  47. 13 12
      Cpp/Platform/Rpc/RpcServer.cc
  48. 5 7
      Cpp/Platform/Rpc/RpcServer.h
  49. 4 4
      Cpp/Platform/Rpc/RpcServerTest.cc
  50. 4 3
      Cpp/Platform/Rpc/RpcSession.cc
  51. 1 1
      Cpp/Platform/Rpc/RpcSession.h
  52. 10 9
      Cpp/Platform/Rpc/Typedef.h
  53. 0 2
      Cpp/Platform/Thread/CMakeLists.txt
  54. 18 28
      Cpp/Platform/Thread/CountBarrierTest.cc
  55. 0 39
      Cpp/Platform/Thread/ThreadPoolTest.cc
  56. 0 28
      Cpp/ThirdParty/boost/threadpool.hpp
  57. 0 215
      Cpp/ThirdParty/boost/threadpool/detail/future.hpp
  58. 0 85
      Cpp/ThirdParty/boost/threadpool/detail/locking_ptr.hpp
  59. 0 453
      Cpp/ThirdParty/boost/threadpool/detail/pool_core.hpp
  60. 0 65
      Cpp/ThirdParty/boost/threadpool/detail/scope_guard.hpp
  61. 0 115
      Cpp/ThirdParty/boost/threadpool/detail/worker_thread.hpp
  62. 0 144
      Cpp/ThirdParty/boost/threadpool/future.hpp
  63. 0 232
      Cpp/ThirdParty/boost/threadpool/pool.hpp
  64. 0 70
      Cpp/ThirdParty/boost/threadpool/pool_adaptors.hpp
  65. 0 262
      Cpp/ThirdParty/boost/threadpool/scheduling_policies.hpp
  66. 0 83
      Cpp/ThirdParty/boost/threadpool/shutdown_policies.hpp
  67. 0 99
      Cpp/ThirdParty/boost/threadpool/size_policies.hpp
  68. 0 168
      Cpp/ThirdParty/boost/threadpool/task_adaptors.hpp

+ 13 - 9
Cpp/CMakeLists.txt

@@ -29,19 +29,18 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/ThirdParty)
 FIND_PACKAGE(Protobuf REQUIRED)
 INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIRS})
 
-FIND_PACKAGE(Perftools REQUIRED)
-INCLUDE_DIRECTORIES(${PERFTOOLS_INCLUDE_DIRS})
-
 FIND_PACKAGE(MysqlConnector)
 INCLUDE_DIRECTORIES(${MYSQL_CONNECTOR_INCLUDE_DIRS})
 
+FIND_PACKAGE(Perftools REQUIRED)
+
 FIND_PACKAGE(Mono)
 
-FIND_PACKAGE(Boost COMPONENTS log)
-FIND_PACKAGE(Boost REQUIRED thread system filesystem)
 SET(Boost_USE_STATIC_LIBS    ON)
 SET(Boost_USE_MULTITHREADED  ON)
-SET(Boost_USE_STATIC_RUNTIME OFF)
+SET(Boost_USE_STATIC_RUNTIME ON)
+FIND_PACKAGE(Boost REQUIRED thread system filesystem log)
+
 
 # 设置第三方库
 SET(ThirdPartyLibs
@@ -57,27 +56,32 @@ ENDIF()
 
 IF(TCMALLOC)
 	SET(ThirdPartyLibs ${ThirdPartyLibs} ${PERFTOOLS_DEBUG_LIBRARIES})
+	INCLUDE_DIRECTORIES(${PERFTOOLS_INCLUDE_DIRS})
 ENDIF()
 
 IF(PROFILE)
 	SET(ThirdPartyLibs ${ThirdPartyLibs} ${PERFTOOLS_PROFILE_LIBRARIES})
+	INCLUDE_DIRECTORIES(${PERFTOOLS_INCLUDE_DIRS})
 ENDIF()
 
 # 设置编译选项
 IF(WIN32)
-	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MTd /Zi /WX /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /wd4819")
+	SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
+	SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
+	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi /WX /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /wd4819")
 	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:libc.lib")
 	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:libcmt.lib")
 	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:msvcrt.lib")
 	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:libcd.lib")
 	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:msvcrtd.lib")
 	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:msvcprtd.lib")
-	ADD_DEFINITIONS(-DBOOST_ALL_NO_LIB -D_WIN32_WINNT=0x0601 -DGLOG_NO_ABBREVIATED_SEVERITIES -DGOOGLE_GLOG_DLL_DECL= -DGFLAGS_DLL_DECL= -DGFLAGS_DLL_DECLARE_FLAG= -DGFLAGS_DLL_DEFINE_FLAG=)
+	ADD_DEFINITIONS(-DBOOST_ALL_NO_LIB -D_WIN32_WINNT=0x0601)
+	# gtest gmock 用到std::tuple超过了默认最大模板参数
+	ADD_DEFINITIONS(-D_VARIADIC_MAX=10)
 ELSEIF(UNIX)
 	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
 ENDIF()
 
 # 子目录
 ADD_SUBDIRECTORY(Platform)
-ADD_SUBDIRECTORY(Game)
 ADD_SUBDIRECTORY(ThirdParty)

+ 0 - 48
Cpp/Game/BehaviorTree/BehaviorNode.h

@@ -1,48 +0,0 @@
-#ifndef BEHAVIORTREE_BEHAVIORNODE_H
-#define BEHAVIORTREE_BEHAVIORNODE_H
-
-#include <string>
-#include "Base/Typedef.h"
-
-namespace Egametang {
-
-class ContexIf;
-class BehaviorNodeConf;
-
-class BehaviorNode
-{
-private:
-	int32 type;
-
-public:
-	BehaviorNode(int32 type): type(type)
-	{
-	}
-
-	virtual ~BehaviorNode()
-	{
-	}
-
-	int32 Type() const
-	{
-		return type;
-	}
-
-	virtual void AddChildNode(BehaviorNode *node)
-	{
-	}
-
-	virtual bool Run(ContexIf* contex) = 0;
-
-	virtual std::string ToString() = 0;
-};
-
-class BehaviorNodeFactoryIf
-{
-public:
-	virtual BehaviorNode* GetInstance(const BehaviorNodeConf& conf) = 0;
-};
-
-} // namespace Egametang
-
-#endif // BEHAVIORTREE_BEHAVIORNODE_H

+ 0 - 54
Cpp/Game/BehaviorTree/BehaviorTree.cc

@@ -1,54 +0,0 @@
-#include <boost/format.hpp>
-#include "Base/Typedef.h"
-#include "BehaviorTree/BehaviorTree.h"
-#include "BehaviorTree/NodeFactories.h"
-#include "BehaviorTree/BehaviorTreeConf.pb.h"
-
-namespace Egametang {
-
-BehaviorTree::BehaviorTree(NodeFactories& factories, const BehaviorTreeConf& treeConf):
-		node(nullptr)
-{
-	type = treeConf.type();
-
-	if (treeConf.has_node())
-	{
-		const BehaviorNodeConf& nodeConf = treeConf.node();
-		BuildTree(factories, nodeConf, node);
-	}
-}
-
-void BehaviorTree::BuildTree(
-		NodeFactories& factories, const BehaviorNodeConf& nodeConf,
-		BehaviorNode*& node)
-{
-	int32 type = nodeConf.type();
-	node = factories.GetInstance(nodeConf);
-	for (int i = 0; i < nodeConf.node_size(); ++i)
-	{
-		const BehaviorNodeConf& logicNodeConf = nodeConf.node(i);
-		BehaviorNode* logicNode = nullptr;
-		BuildTree(factories, logicNodeConf, logicNode);
-		node->AddChildNode(logicNode);
-	}
-}
-
-BehaviorTree::~BehaviorTree()
-{
-	delete node;
-}
-
-void BehaviorTree::Run(ContexIf* contex)
-{
-	node->Run(contex);
-}
-
-std::string BehaviorTree::ToString()
-{
-	boost::format format("type: %1%\node: %2%");
-	format % type % node->ToString();
-	return format.str();
-}
-
-} // namespace Egametang
-

+ 0 - 34
Cpp/Game/BehaviorTree/BehaviorTree.h

@@ -1,34 +0,0 @@
-#ifndef BEHAVIORTREE_BEHAVIORTREE_H
-#define BEHAVIORTREE_BEHAVIORTREE_H
-
-#include "BehaviorTree/BehaviorNode.h"
-
-namespace Egametang {
-
-class BehaviorTreeConf;
-class BehaviorNodeConf;
-class NodeFactories;
-
-class BehaviorTree
-{
-private:
-	int type;
-	BehaviorNode* node;
-
-	void BuildTree(NodeFactories& factories, const BehaviorNodeConf& nodeConf,
-			BehaviorNode*& node);
-
-public:
-	BehaviorTree(NodeFactories& factories, const BehaviorTreeConf& treeConf);
-
-	~BehaviorTree();
-
-	void Run(ContexIf* contex);
-
-	std::string ToString();
-};
-
-} // namespace Egametang
-
-
-#endif // BEHAVIORTREE_BEHAVIORTREE_H

+ 0 - 18
Cpp/Game/BehaviorTree/BehaviorTreeConf.proto

@@ -1,18 +0,0 @@
-package Egametang;
-
-message BehaviorNodeConf
-{
-	required int32 type = 1;
-	// 条件需要的参数
-	repeated int32 args = 2;
-	// 包含多个子节点
-	repeated BehaviorNodeConf node = 3;
-};
-
-message BehaviorTreeConf
-{
-	// 行为树类型: AI, ON_HIT, ON_HITTED ...
-	required int32 type = 1;
-	// 行为树节点
-	required BehaviorNodeConf node = 2;
-};

+ 0 - 42
Cpp/Game/BehaviorTree/BuffType.cc

@@ -1,42 +0,0 @@
-#include "BehaviorTree/BuffType.h"
-#include "BehaviorTree/ContexIf.h"
-#include "BehaviorTree/SpellBuff.h"
-#include "BehaviorTree/CombatContex.h"
-#include "BehaviorTree/BehaviorTreeConf.pb.h"
-
-namespace Egametang {
-
-BuffType::BuffType(int32 type, int32 buff_type):
-		BehaviorNode(type), buffType(buff_type)
-{
-}
-
-BuffType::~BuffType()
-{
-}
-
-bool BuffType::Run(ContexIf* contex)
-{
-	CombatContex* combat_contex = reinterpret_cast<CombatContex*>(contex);
-	Buff* buff = combat_contex->GetBuff();
-	return buff->buffType == buffType;
-}
-
-std::string BuffType::ToString()
-{
-	std::string s;
-	s += "BuffType: \n";
-	return s;
-}
-
-BuffTypeFactory::~BuffTypeFactory()
-{
-}
-
-BehaviorNode* BuffTypeFactory::GetInstance(const BehaviorNodeConf& conf)
-{
-	return new BuffType(conf.type(), conf.args(0));
-}
-
-} // namespace Egametang
-

+ 0 - 36
Cpp/Game/BehaviorTree/BuffType.h

@@ -1,36 +0,0 @@
-#ifndef BEHAVIORTREE_BUFFTYPE_H
-#define BEHAVIORTREE_BUFFTYPE_H
-
-#include "BehaviorTree/BehaviorNode.h"
-
-namespace Egametang {
-
-class ContexIf;
-
-class BuffType: public BehaviorNode
-{
-private:
-	int32 buffType;
-
-public:
-	BuffType(int32 type, int buff_type);
-
-	virtual ~BuffType();
-
-	virtual bool Run(ContexIf* contex);
-
-	virtual std::string ToString();
-};
-
-class BuffTypeFactory: public BehaviorNodeFactoryIf
-{
-public:
-	virtual ~BuffTypeFactory();
-
-	virtual BehaviorNode* GetInstance(const BehaviorNodeConf& conf);
-};
-
-} // namespace Egametang
-
-
-#endif // BEHAVIORTREE_BUFFTYPE_H

+ 0 - 38
Cpp/Game/BehaviorTree/CMakeLists.txt

@@ -1,38 +0,0 @@
-PROTOBUF_GENERATE_CPP(proto_srcs proto_hdrs
-	BehaviorTreeConf.proto
-)
-
-FILE(GLOB Header "*.h")
-
-SET(BehaviorTreeSrc
-	${Header}
-	${proto_hdrs}
-	${proto_srcs}
-	BuffType.cc
-	ChangeHealth.cc
-	CombatContex.cc
-	GameEvents.cc
-	NodeFactories.cc
-	NotNode.cc
-	SelectorNode.cc
-	SequenceNode.cc
-	BehaviorTree.cc
-)
-
-ADD_LIBRARY(BehaviorTree ${BehaviorTreeSrc})
-SET_PROPERTY(TARGET BehaviorTree PROPERTY FOLDER "Game")
-
-ADD_EXECUTABLE(GameEventsTest GameEventsTest.cc)
-
-SET(Tests
-	GameEventsTest
-)
-
-FOREACH(Test ${Tests})
-	TARGET_LINK_LIBRARIES(${Test}
-		BehaviorTree
-		${ThirdPartyLibs}
-	)
-	ADD_TEST(${Test} ${Test})
-	SET_PROPERTY(TARGET ${Test} PROPERTY FOLDER "Tests/Game/BehaviorTree")
-ENDFOREACH()

+ 0 - 50
Cpp/Game/BehaviorTree/ChangeHealth.cc

@@ -1,50 +0,0 @@
-#include "BehaviorTree/ChangeHealth.h"
-#include "BehaviorTree/CombatContex.h"
-#include "BehaviorTree/BehaviorTreeConf.pb.h"
-#include "BehaviorTree/SpellBuff.h"
-
-namespace Egametang {
-
-ChangeHealth::ChangeHealth(int32 type, int32 unit, int32 value):
-		BehaviorNode(type), unit(unit), value(value)
-{
-}
-
-ChangeHealth::~ChangeHealth()
-{
-}
-
-bool ChangeHealth::Run(ContexIf *contex)
-{
-	CombatContex* combat_contex = reinterpret_cast<CombatContex*>(contex);
-	Spell* spell = combat_contex->GetSpell();
-
-	Unit* target = nullptr;
-	if (unit == 0)
-	{
-		target = spell->caster;
-	}
-	else
-	{
-		target = spell->victim;
-	}
-
-	target->health += value;
-
-	return true;
-}
-
-std::string ChangeHealth::ToString()
-{
-	std::string s;
-	s += "ChangeHealth: \n";
-	return s;
-}
-
-BehaviorNode* ChangeHealthFactory::GetInstance(const BehaviorNodeConf& conf)
-{
-	return new ChangeHealth(conf.type(), conf.args(0), conf.args(1));
-}
-
-} // namespace Egametang
-

+ 0 - 33
Cpp/Game/BehaviorTree/ChangeHealth.h

@@ -1,33 +0,0 @@
-#ifndef BEHAVIORTREE_CHANGEHEALTH_H
-#define BEHAVIORTREE_CHANGEHEALTH_H
-
-#include "Base/Typedef.h"
-#include "BehaviorTree/BehaviorNode.h"
-
-namespace Egametang {
-
-class ChangeHealth: public BehaviorNode
-{
-private:
-	int32 unit;
-	int32 value;
-
-public:
-	ChangeHealth(int32 type, int32 unit, int32 value);
-
-	virtual ~ChangeHealth();
-
-	virtual bool Run(ContexIf* contex);
-
-	virtual std::string ToString();
-};
-
-class ChangeHealthFactory: public BehaviorNodeFactoryIf
-{
-public:
-	virtual BehaviorNode* GetInstance(const BehaviorNodeConf& conf);
-};
-
-} // namespace Egametang
-
-#endif // BEHAVIORTREE_CHANGEHEALTH_H

+ 0 - 24
Cpp/Game/BehaviorTree/CombatContex.cc

@@ -1,24 +0,0 @@
-#include "BehaviorTree/CombatContex.h"
-
-namespace Egametang {
-
-CombatContex::CombatContex(Spell* spell, Buff* buff):
-	spell(spell), buff(buff)
-{
-}
-
-CombatContex::~CombatContex()
-{
-}
-
-Spell* CombatContex::GetSpell()
-{
-	return spell;
-}
-
-Buff* CombatContex::GetBuff()
-{
-	return buff;
-}
-
-} // namespace Egametang

+ 0 - 26
Cpp/Game/BehaviorTree/CombatContex.h

@@ -1,26 +0,0 @@
-#ifndef BEHAVIORTREE_COMBATCONTEX_H
-#define BEHAVIORTREE_COMBATCONTEX_H
-
-#include "BehaviorTree/ContexIf.h"
-
-namespace Egametang {
-
-class CombatContex: public ContexIf
-{
-private:
-	Spell* spell;
-	Buff* buff;
-
-public:
-	CombatContex(Spell* spell, Buff* buff);
-	~CombatContex();
-
-	virtual Spell* GetSpell();
-
-	virtual Buff* GetBuff();
-};
-
-} // namespace Egametang
-
-#endif // BEHAVIORTREE_COMBATCONTEX_H
-

+ 0 - 20
Cpp/Game/BehaviorTree/ContexIf.h

@@ -1,20 +0,0 @@
-#ifndef BEHAVIORTREE_CONTEXIF_H
-#define BEHAVIORTREE_CONTEXIF_H
-
-#include <stddef.h>
-#include "BehaviorTree/SpellBuff.h"
-
-namespace Egametang {
-
-class ContexIf
-{
-public:
-	virtual ~ContexIf()
-	{
-	}
-};
-
-} // namespace Egametang
-
-#endif // BEHAVIORTREE_CONTEXIF_H
-

+ 0 - 36
Cpp/Game/BehaviorTree/EventDefine.h

@@ -1,36 +0,0 @@
-#ifndef BEHAVIORTREE_EVENTDEFINE_H
-#define BEHAVIORTREE_EVENTDEFINE_H
-
-namespace Egametang {
-
-enum EventType
-{
-	ON_SPELL_START     = 0,
-	ON_SPELL_FINISH    = 1,
-	ON_ADD_BUFF        = 2,
-	ON_REMOVE_BUFF     = 3,
-	ON_HITTED          = 4,
-	ON_HIT             = 5
-};
-
-enum NodeType
-{
-	SEQUENCE           = 1,
-	SELECTOR           = 2,
-
-	NOT                = 11,
-
-	BUFF_TYPE          = 101,
-
-	CHANGE_HEALTH      = 1001
-};
-
-enum SpellUnit
-{
-	CASTER = 0,
-	VICTIM = 1
-};
-
-}  // namespace Egametang
-
-#endif // BEHAVIORTREE_EVENTDEFINE_H

+ 0 - 42
Cpp/Game/BehaviorTree/GameEvents.cc

@@ -1,42 +0,0 @@
-#include <boost/foreach.hpp>
-#include "Base/Marcos.h"
-#include "Base/Typedef.h"
-#include "BehaviorTree/GameEvents.h"
-#include "BehaviorTree/BehaviorTreeConf.pb.h"
-
-namespace Egametang {
-
-GameEvents::GameEvents(NodeFactories& factories):
-		factories(factories), events(100)
-{
-}
-
-GameEvents::~GameEvents()
-{
-	foreach (std::list<BehaviorTree*> list, events)
-	{
-		foreach (BehaviorTree* tree, list)
-		{
-			delete tree;
-		}
-	}
-}
-
-void GameEvents::AddEvent(const BehaviorTreeConf& conf)
-{
-	int32 type = conf.type();
-	BehaviorTree* event = new BehaviorTree(factories, conf);
-	events[type].push_back(event);
-}
-
-void GameEvents::Excute(int type, ContexIf* contex)
-{
-	std::list<BehaviorTree*>& es = events[type];
-
-	for (std::list<BehaviorTree*>::iterator iter = es.begin(); iter != es.end(); ++iter)
-	{
-		(*iter)->Run(contex);
-	}
-}
-
-} // namespace Egametang

+ 0 - 30
Cpp/Game/BehaviorTree/GameEvents.h

@@ -1,30 +0,0 @@
-#ifndef BEHAVIORTREE_GAMEEVENTS_H
-#define BEHAVIORTREE_GAMEEVENTS_H
-
-#include <list>
-#include <vector>
-#include "BehaviorTree/BehaviorTree.h"
-
-namespace Egametang {
-
-class NodeFactories;
-
-class GameEvents
-{
-private:
-	NodeFactories& factories;
-	std::vector<std::list<BehaviorTree*> > events;
-
-public:
-	GameEvents(NodeFactories& factories);
-
-	~GameEvents();
-
-	void AddEvent(const BehaviorTreeConf& conf);
-
-	void Excute(int type, ContexIf* contex);
-};
-
-} // namespace Egametang
-
-#endif // BEHAVIORTREE_GAMEEVENTS_H

+ 0 - 75
Cpp/Game/BehaviorTree/GameEventsTest.cc

@@ -1,75 +0,0 @@
-#include <fcntl.h>
-#include <fstream>
-#include <gtest/gtest.h>
-#include <google/protobuf/text_format.h>
-#include "BehaviorTree/GameEvents.h"
-#include "BehaviorTree/NodeFactories.h"
-#include "BehaviorTree/BehaviorTreeConf.pb.h"
-#include "BehaviorTree/SpellBuff.h"
-#include "BehaviorTree/CombatContex.h"
-#include "BehaviorTree/EventDefine.h"
-
-namespace Egametang {
-
-class GameEventsTest: public testing::Test
-{
-protected:
-	NodeFactories factories;
-	GameEvents game_events;
-
-public:
-	GameEventsTest():factories(), game_events(factories)
-	{
-	}
-
-	virtual ~GameEventsTest()
-	{
-	}
-};
-
-static void FileToString(const std::string& file, std::string& string)
-{
-	std::ifstream in(file.c_str());
-	std::ostringstream os;
-	os << in.rdbuf();
-	string = os.str();
-	in.close();
-}
-
-TEST_F(GameEventsTest, Vampire)
-{
-	std::string file = "../../../Cpp/Game/BehaviorTree/Vampire.txt";
-	std::string string;
-	FileToString(file, string);
-	BehaviorTreeConf conf;
-	google::protobuf::TextFormat::ParseFromString(string, &conf);
-	game_events.AddEvent(conf);
-
-	Unit caster;
-	Unit victim;
-	caster.health = 2000;
-	victim.health = 2000;
-	Spell spell;
-	Buff buff;
-	spell.caster = &caster;
-	spell.victim = &victim;
-	CombatContex contex(&spell, &buff);
-
-	game_events.Excute(ON_HIT, &contex);
-	ASSERT_EQ(2000, caster.health);
-	ASSERT_EQ(2000, victim.health);
-
-	buff.buffType = 2;
-	game_events.Excute(ON_HIT, &contex);
-	ASSERT_EQ(2100, caster.health);
-	ASSERT_EQ(1900, victim.health);
-}
-
-} // namespace Egametang
-
-
-int main(int argc, char* argv[])
-{
-	testing::InitGoogleTest(&argc, argv);
-	return RUN_ALL_TESTS();
-}

+ 0 - 46
Cpp/Game/BehaviorTree/NodeFactories.cc

@@ -1,46 +0,0 @@
-#include "Base/Typedef.h"
-#include "BehaviorTree/NotNode.h"
-#include "BehaviorTree/EventDefine.h"
-#include "BehaviorTree/SequenceNode.h"
-#include "BehaviorTree/SelectorNode.h"
-#include "BehaviorTree/BuffType.h"
-#include "BehaviorTree/ChangeHealth.h"
-#include "BehaviorTree/NodeFactories.h"
-#include "BehaviorTree/BehaviorTreeConf.pb.h"
-#include "BehaviorTree/EventDefine.h"
-
-namespace Egametang {
-
-NodeFactories::NodeFactories(): factories(2000, (BehaviorNodeFactoryIf*)(nullptr))
-{
-	// 节点
-	factories[SEQUENCE] = new SequenceNodeFactory();
-	factories[SELECTOR] = new SelectorNodeFactory();
-	factories[NOT] = new NotNodeFactory();
-
-	// 叶子节点
-	factories[BUFF_TYPE] = new BuffTypeFactory();
-	factories[CHANGE_HEALTH] = new ChangeHealthFactory();
-}
-
-NodeFactories::~NodeFactories()
-{
-	for (std::size_t i = 0; i < factories.size(); ++i)
-	{
-		if (factories[i] == nullptr)
-		{
-			continue;
-		}
-		delete factories[i];
-	}
-}
-
-BehaviorNode* NodeFactories::GetInstance(const BehaviorNodeConf& conf)
-{
-	int32 type = conf.type();
-	return factories[type]->GetInstance(conf);
-}
-
-}
-
-

+ 0 - 24
Cpp/Game/BehaviorTree/NodeFactories.h

@@ -1,24 +0,0 @@
-#ifndef BEHAVIORTREE_NODEFACTORIES_H
-#define BEHAVIORTREE_NODEFACTORIES_H
-
-#include <vector>
-#include "BehaviorTree/BehaviorNode.h"
-
-namespace Egametang {
-
-class NodeFactories
-{
-private:
-	std::vector<BehaviorNodeFactoryIf*> factories;
-
-public:
-	NodeFactories();
-
-	virtual ~NodeFactories();
-
-	virtual BehaviorNode* GetInstance(const BehaviorNodeConf& conf);
-};
-
-} // namespace Egametang
-
-#endif // BEHAVIORTREE_NODEFACTORIES_H

+ 0 - 40
Cpp/Game/BehaviorTree/NotNode.cc

@@ -1,40 +0,0 @@
-#include <stddef.h>
-#include "BehaviorTree/NotNode.h"
-#include "BehaviorTree/BehaviorTreeConf.pb.h"
-
-namespace Egametang {
-
-NotNode::NotNode(int32 type): BehaviorNode(type), node(nullptr)
-{
-}
-
-NotNode::~NotNode()
-{
-	delete node;
-}
-
-bool NotNode::Run(ContexIf* contex)
-{
-	return !node->Run(contex);
-}
-
-void NotNode::AddChildNode(BehaviorNode *node)
-{
-	this->node = node;
-}
-
-std::string NotNode::ToString()
-{
-	std::string s;
-	s += "NotNode: \n";
-	s += "    " + node->ToString() + "\n";
-	return s;
-}
-
-BehaviorNode* NotNodeFactory::GetInstance(const BehaviorNodeConf& conf)
-{
-	return new NotNode(conf.type());
-}
-
-} // namespace Egametang
-

+ 0 - 34
Cpp/Game/BehaviorTree/NotNode.h

@@ -1,34 +0,0 @@
-#ifndef BEHAVIORTREE_NOTNODE_H
-#define BEHAVIORTREE_NOTNODE_H
-
-#include "BehaviorTree/BehaviorNode.h"
-
-namespace Egametang {
-
-class NotNode: public BehaviorNode
-{
-private:
-	BehaviorNode* node;
-
-public:
-	NotNode(int32 type);
-
-	virtual ~NotNode();
-
-	virtual bool Run(ContexIf* contex);
-
-	virtual void AddChildNode(BehaviorNode *node);
-
-	virtual std::string ToString();
-};
-
-class NotNodeFactory: public BehaviorNodeFactoryIf
-{
-public:
-	virtual BehaviorNode* GetInstance(const BehaviorNodeConf& conf);
-};
-
-} // namespace Egametang
-
-
-#endif // BEHAVIORTREE_NOTNODE_H

+ 0 - 54
Cpp/Game/BehaviorTree/SelectorNode.cc

@@ -1,54 +0,0 @@
-#include <boost/foreach.hpp>
-#include "Base/Marcos.h"
-#include "BehaviorTree/SelectorNode.h"
-#include "BehaviorTree/BehaviorTreeConf.pb.h"
-
-namespace Egametang {
-
-SelectorNode::SelectorNode(int32 type): BehaviorNode(type)
-{
-}
-
-SelectorNode::~SelectorNode()
-{
-	foreach (BehaviorNode* node, nodes)
-	{
-		delete node;
-	}
-}
-
-bool SelectorNode::Run(ContexIf* contex)
-{
-	foreach (BehaviorNode* node, nodes)
-	{
-		if (node->Run(contex))
-		{
-			return true;
-		}
-	}
-	return false;
-}
-
-void SelectorNode::AddChildNode(BehaviorNode *node)
-{
-	nodes.push_back(node);
-}
-
-std::string SelectorNode::ToString()
-{
-	std::string s;
-	s += "SelectorNode: \n";
-	foreach (BehaviorNode* node, nodes)
-	{
-		s += "    " + node->ToString() + "\n";
-	}
-	return s;
-}
-
-BehaviorNode* SelectorNodeFactory::GetInstance(const BehaviorNodeConf& conf)
-{
-	return new SelectorNode(conf.type());
-}
-
-} // namespace Egametang
-

+ 0 - 35
Cpp/Game/BehaviorTree/SelectorNode.h

@@ -1,35 +0,0 @@
-#ifndef BEHAVIORTREE_SELECTORNODE_H
-#define BEHAVIORTREE_SELECTORNODE_H
-
-#include <list>
-#include "BehaviorTree/BehaviorNode.h"
-
-namespace Egametang {
-
-class SelectorNode: public BehaviorNode
-{
-private:
-	std::list<BehaviorNode*> nodes;
-
-public:
-	SelectorNode(int32 type);
-
-	virtual ~SelectorNode();
-
-	virtual bool Run(ContexIf* contex);
-
-	virtual void AddChildNode(BehaviorNode *node);
-
-	virtual std::string ToString();
-};
-
-class SelectorNodeFactory: public BehaviorNodeFactoryIf
-{
-public:
-	virtual BehaviorNode* GetInstance(const BehaviorNodeConf& conf);
-};
-
-} // namespace Egametang
-
-
-#endif // BEHAVIORTREE_SELECTORNODE_H

+ 0 - 54
Cpp/Game/BehaviorTree/SequenceNode.cc

@@ -1,54 +0,0 @@
-#include <boost/foreach.hpp>
-#include "Base/Marcos.h"
-#include "BehaviorTree/SequenceNode.h"
-#include "BehaviorTree/BehaviorTreeConf.pb.h"
-
-namespace Egametang {
-
-SequenceNode::SequenceNode(int32 type): BehaviorNode(type)
-{
-}
-
-SequenceNode::~SequenceNode()
-{
-	foreach (BehaviorNode* node, nodes)
-	{
-		delete node;
-	}
-}
-
-bool SequenceNode::Run(ContexIf* contex)
-{
-	foreach (BehaviorNode* node, nodes)
-	{
-		if (!node->Run(contex))
-		{
-			return false;
-		}
-	}
-	return true;
-}
-
-void SequenceNode::AddChildNode(BehaviorNode *node)
-{
-	nodes.push_back(node);
-}
-
-std::string SequenceNode::ToString()
-{
-	std::string s;
-	s += "SequenceNode: \n";
-	foreach (BehaviorNode* node, nodes)
-	{
-		s += "    " + node->ToString() + "\n";
-	}
-	return s;
-}
-
-BehaviorNode* SequenceNodeFactory::GetInstance(const BehaviorNodeConf& conf)
-{
-	return new SequenceNode(conf.type());
-}
-
-} // namespace Egametang
-

+ 0 - 35
Cpp/Game/BehaviorTree/SequenceNode.h

@@ -1,35 +0,0 @@
-#ifndef BEHAVIORTREE_SEQUENCENODE_H
-#define BEHAVIORTREE_SEQUENCENODE_H
-
-#include <list>
-#include "BehaviorTree/BehaviorNode.h"
-
-namespace Egametang {
-
-class SequenceNode: public BehaviorNode
-{
-private:
-	std::list<BehaviorNode*> nodes;
-
-public:
-	SequenceNode(int32 type);
-
-	virtual ~SequenceNode();
-
-	virtual bool Run(ContexIf* contex);
-
-	virtual void AddChildNode(BehaviorNode *node);
-
-	virtual std::string ToString();
-};
-
-class SequenceNodeFactory: public BehaviorNodeFactoryIf
-{
-public:
-	virtual BehaviorNode* GetInstance(const BehaviorNodeConf& conf);
-};
-
-} // namespace Egametang
-
-
-#endif // BEHAVIORTREE_SEQUENCENODE_H

+ 0 - 33
Cpp/Game/BehaviorTree/SpellBuff.h

@@ -1,33 +0,0 @@
-#ifndef BEHAVIORTREE_SPELLBUFF_H
-#define BEHAVIORTREE_SPELLBUFF_H
-
-namespace Egametang {
-
-class Unit
-{
-public:
-	int health;
-};
-
-class Spell
-{
-public:
-	Unit* caster;
-	Unit* victim;
-};
-
-class Buff
-{
-public:
-	int buffType;
-
-public:
-	Buff(): buffType(0)
-	{
-	}
-};
-
-} // namespace Egametang
-
-
-#endif // BEHAVIORTREE_SPELLBUFF_H

+ 0 - 26
Cpp/Game/BehaviorTree/Vampire.txt

@@ -1,26 +0,0 @@
-type: 5
-node:
-{
-	type: 1
-	node:
-	{
-		type: 101
-		args: 2
-	}
-	node:
-	{
-		type: 1
-		node:
-		{
-			type: 1001
-			args: 0
-			args: 100
-		}
-		node:
-		{
-			type: 1001
-			args: 1
-			args: -100
-		}
-	}
-}

+ 0 - 1
Cpp/Game/CMakeLists.txt

@@ -1 +0,0 @@
-ADD_SUBDIRECTORY(BehaviorTree)

+ 1 - 1
Cpp/Platform/Base/Exception.h

@@ -11,7 +11,7 @@ struct Exception: virtual std::exception, virtual boost::exception
 {
 };
 typedef boost::error_info<struct TagErrNO, int> ErrNO;
-typedef boost::error_info<struct TagErrStr, std::string> ErrStr;
+typedef boost::error_info<struct TagErrStr, std::string> ErrInfo;
 
 }
 

+ 5 - 5
Cpp/Platform/Base/Typedef.h

@@ -1,7 +1,7 @@
 #ifndef BASE_TYPEDEFS_H
 #define BASE_TYPEDEFS_H
 
-#include <memory>
+#include <boost/shared_ptr.hpp>
 #include <boost/cstdint.hpp>
 #include <google/protobuf/service.h>
 #include <google/protobuf/message.h>
@@ -19,12 +19,12 @@ typedef boost::uint64_t uint64;
 
 // smart_ptr typedef
 
-typedef std::shared_ptr<int> IntPtr;
-typedef std::shared_ptr<std::string> StringPtr;
+typedef boost::shared_ptr<int> IntPtr;
+typedef boost::shared_ptr<std::string> StringPtr;
 
 // google
-typedef std::shared_ptr<google::protobuf::Service> ProtobufServicePtr;
-typedef std::shared_ptr<google::protobuf::Message> ProtobufMessagePtr;
+typedef boost::shared_ptr<google::protobuf::Service> ProtobufServicePtr;
+typedef boost::shared_ptr<google::protobuf::Message> ProtobufMessagePtr;
 
 } // namespace Egametang
 

+ 1 - 4
Cpp/Platform/CMakeLists.txt

@@ -1,5 +1,6 @@
 ADD_SUBDIRECTORY(Thread)
 ADD_SUBDIRECTORY(Rpc)
+ADD_SUBDIRECTORY(Log)
 
 IF(MONO_FOUND)
 	ADD_SUBDIRECTORY(Mono)
@@ -7,8 +8,4 @@ ENDIF()
 
 IF(MYSQL_CONNECTOR_FOUND)
 	ADD_SUBDIRECTORY(Orm)
-ENDIF()
-
-IF(Boost_Log_FOUND)
-	ADD_SUBDIRECTORY(Log)
 ENDIF()

+ 35 - 42
Cpp/Platform/Log/Log.cc

@@ -3,81 +3,74 @@
 
 #include <fstream>
 #include <iostream>
-#include <memory>
-#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <string>
+#include <boost/make_shared.hpp>
+#include <boost/scoped_ptr.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/log/common.hpp>
-#include <boost/log/filters.hpp>
-#include <boost/log/formatters.hpp>
+#include <boost/log/expressions.hpp>
 #include <boost/log/attributes.hpp>
-#include <boost/log/sinks/text_multifile_backend.hpp>
-#include <boost/log/attributes/current_thread_id.hpp>
-#include <boost/date_time/posix_time/posix_time_types.hpp>
-#include <boost/log/sinks/sync_frontend.hpp>
-#include <boost/log/sinks/text_ostream_backend.hpp>
-#include <gflags/gflags.h>
+#include <boost/log/sinks.hpp>
+#include <boost/log/sources/logger.hpp>
+#include <boost/log/utility/empty_deleter.hpp>
+#include <boost/log/utility/manipulators/add_value.hpp>
+#include <boost/log/attributes/scoped_attribute.hpp>
+#include <boost/log/support/date_time.hpp>
 #include "Log/Log.h"
-
-DEFINE_bool(logtoconsole, false, "log messages go to stderr instead of logfiles");
+#include "Base/Exception.h"
 
 using namespace boost::log;
 
 namespace Egametang {
 
-std::string FileName(const char* s)
+std::string FileName(std::string s)
 {
 	boost::filesystem::path path(s);
 	return path.filename().string();
 }
 
-bool ELog::isInit = false;
-sources::severity_logger<SeverityLevel> ELog::slog;
+boost::scoped_ptr< boost::log::sources::severity_logger<SeverityLevel> > Log::slog;
 
-void ELog::Init(const char* fileName)
+void Log::Init(std::string fileName)
 {
-	if (isInit)
-	{
-		return;
-	}
-	isInit = true;
+	slog.reset(new boost::log::sources::severity_logger<SeverityLevel>());
 
 	auto core = core::get();
 	typedef sinks::synchronous_sink<sinks::text_ostream_backend> text_sink;
-	auto pSink = std::make_shared<text_sink>();
+	auto pSink = boost::make_shared<text_sink>();
 	std::string logFileName = FileName(fileName) + ".log";
-	auto logStream = std::make_shared<std::ofstream>(logFileName.c_str());
+	auto logStream = boost::make_shared<std::ofstream>(logFileName.c_str());
 	if (!logStream->good())
 	{
 		throw std::runtime_error("Failed to open a log file");
 	}
 	pSink->locked_backend()->add_stream(logStream);
 
-	// 是否输出到标准错误
-	if (FLAGS_logtoconsole)
-	{
-		pSink->locked_backend()->add_stream(
-		        std::shared_ptr<std::ostream>(&std::clog, boost::log::empty_deleter()));
-	}
+	pSink->locked_backend()->add_stream(
+		boost::shared_ptr<std::ostream>(&std::clog, boost::log::empty_deleter()));
 
-	pSink->locked_backend()->set_formatter(
-			formatters::format("[%1%][%2%][%3%]%4%")
-				% formatters::attr<unsigned int>("Line #", keywords::format = "%08x")
-				% formatters::date_time<boost::posix_time::ptime>("TimeStamp")
-				% formatters::attr<boost::thread::id>("ThreadID", keywords::format = "%05d")
-				% formatters::message()
+	pSink->set_formatter(
+		expressions::format("[%1%][%2%][%3%]%4%")
+			% expressions::attr< unsigned int >("RecordID")
+			% expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S.%f")
+			% expressions::attr<attributes::current_thread_id::value_type>("ThreadID")
+			% expressions::smessage
 	);
 
-	pSink->set_filter(boost::log::filters::attr<SeverityLevel>("Severity", std::nothrow) >= INFO);
-
-    core->add_global_attribute("Line #", std::make_shared<attributes::counter<unsigned int>>());
-    core->add_global_attribute("TimeStamp", std::make_shared<attributes::local_clock>());
-    core->add_global_attribute("ThreadID", std::make_shared<attributes::current_thread_id>());
+	core->add_global_attribute("RecordID", attributes::counter<unsigned int>(1));
+	core->add_global_attribute("TimeStamp", attributes::local_clock());
+	core->add_global_attribute("ThreadID", attributes::current_thread_id());
 
 	core->add_sink(pSink);
 }
 
-boost::log::sources::severity_logger<SeverityLevel>& ELog::GetSLog()
+boost::log::sources::severity_logger<SeverityLevel>& Log::GetSLog()
 {
-	return slog;
+	if (!slog.get())
+	{
+		throw Exception() << ErrInfo("use log please Init in main function");
+	}
+	return *slog;
 }
 
 } // Egametang

+ 10 - 9
Cpp/Platform/Log/Log.h

@@ -5,32 +5,33 @@
 #define BASE_LOG_H
 
 #include <string>
-#include <memory>
+#include <boost/scoped_ptr.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/shared_ptr.hpp>
 #include <boost/log/trivial.hpp>
 #include <boost/log/sources/severity_logger.hpp>
 
 namespace Egametang {
 
-#define ELOG(level) BOOST_LOG_SEV(ELog::GetSLog(), level) << "[" << FileName(__FILE__) << ":" << __LINE__ << "] "
+#define LOG(level) BOOST_LOG_SEV(Log::GetSLog(), level) << "[" << FileName(__FILE__) << ":" << __LINE__ << "] "
 
-std::string FileName(const char* s);
+std::string FileName(std::string s);
 
 enum SeverityLevel
 {
 	INFO       = 0,
-	WARNING    = 1,
-	ERROR      = 2,
+	WARN       = 1,
+	ERR        = 2,
 	FATAL      = 3,
 };
 
-class ELog: public boost::noncopyable
+class Log: public boost::noncopyable
 {
 private:
-	static bool isInit;
-	static boost::log::sources::severity_logger<SeverityLevel> slog;
+	static boost::scoped_ptr< boost::log::sources::severity_logger<SeverityLevel> > slog;
 
 public:
-	static void Init(const char* fileName);
+	static void Init(std::string fileName);
 	static boost::log::sources::severity_logger<SeverityLevel>& GetSLog();
 };
 }

+ 4 - 9
Cpp/Platform/Log/LogTest.cc

@@ -3,7 +3,7 @@
 
 #include <gtest/gtest.h>
 #include <gmock/gmock.h>
-#include <gflags/gflags.h>
+#include <boost/log/detail/thread_id.hpp>
 #include "Log/Log.h"
 
 namespace Egametang {
@@ -14,7 +14,7 @@ class LogTest: public testing::Test
 
 TEST_F(LogTest, Log)
 {
-	ELOG(INFO) << "Test ELOG Marco!";
+	LOG(INFO) << "Test LOG Marco!";
 }
 
 } // namespace Egametang
@@ -22,11 +22,6 @@ TEST_F(LogTest, Log)
 int main(int argc, char* argv[])
 {
 	testing::InitGoogleTest(&argc, argv);
-	google::ParseCommandLineFlags(&argc, &argv, true);
-	Egametang::ELog::Init(argv[0]);
+	Egametang::Log::Init(argv[0]);
 	return RUN_ALL_TESTS();
-}
-
-
-
-
+}

+ 1 - 1
Cpp/Platform/Orm/DbHelper.h

@@ -30,7 +30,7 @@ public:
 	{
 		std::string sql = select.ToString();
 		ResultSetPtr resultSet(statement->executeQuery(sql));
-		auto dbResult = std::make_shared<DbResult>(resultSet);
+		auto dbResult = boost::make_shared<DbResult>(resultSet);
 		return dbResult;
 	}
 };

+ 1 - 1
Cpp/Platform/Orm/DbResult.h

@@ -26,7 +26,7 @@ public:
 	std::size_t Count();
 
 	template <typename Table>
-	void All(std::vector<std::shared_ptr<Table> >& messages)
+	void All(std::vector<boost::shared_ptr<Table> >& messages)
 	{
 		for (std::size_t i = 0; i < messages.size(); ++i)
 		{

+ 2 - 2
Cpp/Platform/Orm/DbResultTest.cc

@@ -1,7 +1,7 @@
 // Copyright: All Rights Reserved
 // Author: egametang@gmail.com (tanghai)
 
-#include <memory>
+#include <boost/shared_ptr.hpp>
 #include <gtest/gtest.h>
 #include "Orm/DbHelper.h"
 #include "Orm/DbResult.h"
@@ -26,7 +26,7 @@ TEST_F(DbResultTest, One)
 				Where(Column("age") > 10)
 			);
 
-		auto person = std::make_shared<Person>();
+		auto person = boost::make_shared<Person>();
 		result->One(person);
 		ASSERT_EQ(26, person->age());
 	}

+ 10 - 10
Cpp/Platform/Orm/MessageFieldTest.cc

@@ -2,7 +2,7 @@
 // Author: egametang@gmail.com (tanghai)
 
 #include <sstream>
-#include <memory>
+#include <boost/shared_ptr.hpp>
 #include <gtest/gtest.h>
 #include <gmock/gmock.h>
 #include <google/protobuf/descriptor.h>
@@ -170,7 +170,7 @@ TEST_F(MessageFieldTest, GetField_FieldIsMessage)
 
 TEST_F(MessageFieldTest, SetField_FieldIsBool)
 {
-	auto resultSetMock = std::make_shared<ResultSetMock>();
+	auto resultSetMock = boost::make_shared<ResultSetMock>();
 	EXPECT_CALL(*resultSetMock, getBoolean(8))
 		.WillOnce(Return(true))
 		.WillOnce(Return(false));
@@ -189,7 +189,7 @@ TEST_F(MessageFieldTest, SetField_FieldIsBool)
 
 TEST_F(MessageFieldTest, SetField_FieldIsDouble)
 {
-	auto resultSetMock = std::make_shared<ResultSetMock>();
+	auto resultSetMock = boost::make_shared<ResultSetMock>();
 	EXPECT_CALL(*resultSetMock, getDouble(6))
 		.WillOnce(Return(1.00))
 		.WillOnce(Return(12345.6789));
@@ -208,7 +208,7 @@ TEST_F(MessageFieldTest, SetField_FieldIsDouble)
 
 TEST_F(MessageFieldTest, SetField_FieldIsInt32)
 {
-	auto resultSetMock = std::make_shared<ResultSetMock>();
+	auto resultSetMock = boost::make_shared<ResultSetMock>();
 	EXPECT_CALL(*resultSetMock, getInt(2))
 		.WillOnce(Return(1))
 		.WillOnce(Return(0xFFFFFFFF));
@@ -227,7 +227,7 @@ TEST_F(MessageFieldTest, SetField_FieldIsInt32)
 
 TEST_F(MessageFieldTest, SetField_FieldIsInt64)
 {
-	auto resultSetMock = std::make_shared<ResultSetMock>();
+	auto resultSetMock = boost::make_shared<ResultSetMock>();
 	EXPECT_CALL(*resultSetMock, getInt64(1))
 		.WillOnce(Return(1))
 		.WillOnce(Return(0xFFFFFFFFFFFFFFFF));
@@ -246,7 +246,7 @@ TEST_F(MessageFieldTest, SetField_FieldIsInt64)
 
 TEST_F(MessageFieldTest, SetField_FieldIsUInt32)
 {
-	auto resultSetMock = std::make_shared<ResultSetMock>();
+	auto resultSetMock = boost::make_shared<ResultSetMock>();
 	EXPECT_CALL(*resultSetMock, getUInt(3))
 		.WillOnce(Return(1))
 		.WillOnce(Return(0xFFFFFFFF));
@@ -265,7 +265,7 @@ TEST_F(MessageFieldTest, SetField_FieldIsUInt32)
 
 TEST_F(MessageFieldTest, SetField_FieldIsUInt64)
 {
-	auto resultSetMock = std::make_shared<ResultSetMock>();
+	auto resultSetMock = boost::make_shared<ResultSetMock>();
 	EXPECT_CALL(*resultSetMock, getUInt64(4))
 		.WillOnce(Return(1))
 		.WillOnce(Return(0xFFFFFFFFFFFFFFFF));
@@ -284,7 +284,7 @@ TEST_F(MessageFieldTest, SetField_FieldIsUInt64)
 
 TEST_F(MessageFieldTest, SetField_FieldIsString)
 {
-	auto resultSetMock = std::make_shared<ResultSetMock>();
+	auto resultSetMock = boost::make_shared<ResultSetMock>();
 	EXPECT_CALL(*resultSetMock, getString(5))
 		.WillOnce(Return("1"))
 		.WillOnce(Return("tanghai"));
@@ -303,7 +303,7 @@ TEST_F(MessageFieldTest, SetField_FieldIsString)
 
 TEST_F(MessageFieldTest, SetField_FieldIsBytes)
 {
-	auto resultSetMock = std::make_shared<ResultSetMock>();
+	auto resultSetMock = boost::make_shared<ResultSetMock>();
 	EXPECT_CALL(*resultSetMock, getString(7))
 		.WillOnce(Return("1"))
 		.WillOnce(Return("tanghai is a good student"));
@@ -324,7 +324,7 @@ TEST_F(MessageFieldTest, SetField_FieldIsMessage)
 {
 	std::istringstream is;
 	is.str("id: 123 name: \"pen\"");
-	auto resultSetMock = std::make_shared<ResultSetMock>();
+	auto resultSetMock = boost::make_shared<ResultSetMock>();
 	EXPECT_CALL(*resultSetMock, getBlob(9))
 		.WillOnce(Return(&is));
 	Person person;

+ 5 - 5
Cpp/Platform/Orm/Typedef.h

@@ -4,7 +4,7 @@
 #ifndef ORM_TYPEDEF_H
 #define ORM_TYPEDEF_H
 
-#include <memory>
+#include <boost/shared_ptr.hpp>
 #include <cppconn/resultset.h>
 
 namespace Egametang {
@@ -12,10 +12,10 @@ namespace Egametang {
 class DbResult;
 class ResultSetMock;
 
-typedef std::shared_ptr<sql::ResultSet> ResultSetPtr;
-typedef std::shared_ptr<sql::Statement> StatementPtr;
-typedef std::shared_ptr<DbResult> DbResultPtr;
-typedef std::shared_ptr<ResultSetMock> ResultSetMockPtr;
+typedef boost::shared_ptr<sql::ResultSet> ResultSetPtr;
+typedef boost::shared_ptr<sql::Statement> StatementPtr;
+typedef boost::shared_ptr<DbResult> DbResultPtr;
+typedef boost::shared_ptr<ResultSetMock> ResultSetMockPtr;
 
 } // namespace Egametang
 

+ 1 - 1
Cpp/Platform/Python/PythonInterpreter.h

@@ -28,7 +28,7 @@ public:
 	void ImportModule(std::string module);
 
 	template <typename T>
-	void RegisterObjectPtr(std::string name, std::shared_ptr<T> object_ptr)
+	void RegisterObjectPtr(std::string name, boost::shared_ptr<T> object_ptr)
 	{
 		mainNS[name.c_str()] = object_ptr;
 	}

+ 3 - 3
Cpp/Platform/Python/PythonInterpreterTest.cc

@@ -1,5 +1,5 @@
 #include <boost/python.hpp>
-#include <memory>
+#include <boost/shared_ptr.hpp>
 #include <gtest/gtest.h>
 #include "Python/PythonInterpreter.h"
 
@@ -51,7 +51,7 @@ public:
 	}
 };
 
-typedef std::shared_ptr<PersonTest> PersonTestPtr;
+typedef boost::shared_ptr<PersonTest> PersonTestPtr;
 
 BOOST_PYTHON_MODULE(PersonTest)
 {
@@ -70,7 +70,7 @@ TEST_F(PythonInterpreterTest, EnterPythonScript)
 	interpreter.ImportPath("../../../Cpp/Platform/Python/");
 	interpreter.ImportModule("PythonInterpreterTest");
 
-	auto person = std::make_shared<PersonTest>();
+	auto person = boost::make_shared<PersonTest>();
 	interpreter.RegisterObjectPtr("person", person);
 
 	ASSERT_EQ(0, person->Guid());

+ 7 - 6
Cpp/Platform/Rpc/CMakeLists.txt

@@ -23,19 +23,20 @@ ADD_LIBRARY(Rpc ${RpcSrc})
 SET_PROPERTY(TARGET Rpc PROPERTY FOLDER "Platform")
 
 ADD_EXECUTABLE(RpcCommunicatorTest RpcCommunicatorTest.cc)
-ADD_EXECUTABLE(RpcClientTest RpcClientTest.cc)
-ADD_EXECUTABLE(RpcSessionTest RpcSessionTest.cc)
-ADD_EXECUTABLE(RpcServerTest RpcServerTest.cc)
+#ADD_EXECUTABLE(RpcClientTest RpcClientTest.cc)
+#ADD_EXECUTABLE(RpcSessionTest RpcSessionTest.cc)
+#ADD_EXECUTABLE(RpcServerTest RpcServerTest.cc)
 
 SET(Tests 
 	RpcCommunicatorTest
-	RpcClientTest
-	RpcSessionTest
-	RpcServerTest
+#	RpcClientTest
+#	RpcSessionTest
+#	RpcServerTest
 )
 
 FOREACH(Test ${Tests})
 	TARGET_LINK_LIBRARIES(${Test}
+		Log
 		Rpc
 		Thread
 		${ThirdPartyLibs}

+ 4 - 3
Cpp/Platform/Rpc/ResponseHandler.cc

@@ -1,4 +1,5 @@
-#include <memory>
+#include <boost/make_shared.hpp>
+#include <boost/shared_ptr.hpp>
 #include "Rpc/MethodInfo.h"
 #include "Rpc/ResponseHandler.h"
 #include "Rpc/RpcCommunicator.h"
@@ -39,8 +40,8 @@ google::protobuf::Message* ResponseHandler::Response()
 
 void ResponseHandler::Run()
 {
-	auto meta = std::make_shared<RpcMeta>();
-	auto message = std::make_shared<std::string>();
+	auto meta = boost::make_shared<RpcMeta>();
+	auto message = boost::make_shared<std::string>();
 	response->SerializeToString(message.get());
 	meta->id = id;
 	meta->size = message->size();

+ 6 - 5
Cpp/Platform/Rpc/RpcClient.cc

@@ -1,5 +1,6 @@
 #include <boost/bind.hpp>
 #include <boost/asio.hpp>
+#include <boost/make_shared.hpp>
 #include <google/protobuf/message.h>
 #include <google/protobuf/descriptor.h>
 #include "Rpc/RpcCommunicator.h"
@@ -30,8 +31,8 @@ void RpcClient::OnAsyncConnect(const boost::system::error_code& err)
 	{
 		return;
 	}
-	auto recvMeta = std::make_shared<RpcMeta>();
-	auto recvMessage = std::make_shared<std::string>();
+	auto recvMeta = boost::make_shared<RpcMeta>();
+	auto recvMessage = boost::make_shared<std::string>();
 	RecvMeta(recvMeta, recvMessage);
 }
 
@@ -70,13 +71,13 @@ void RpcClient::CallMethod(
 {
 	if (done)
 	{
-		auto request_handler = std::make_shared<RequestHandler>(response, done);
+		auto request_handler = boost::make_shared<RequestHandler>(response, done);
 		requestHandlers[++id] = request_handler;
 	}
 	std::hash<std::string> stringHash;
-	auto message = std::make_shared<std::string>();
+	auto message = boost::make_shared<std::string>();
 	request->SerializePartialToString(message.get());
-	auto meta = std::make_shared<RpcMeta>();
+	auto meta = boost::make_shared<RpcMeta>();
 	meta->size = message->size();
 	meta->id = id;
 	meta->method = stringHash(method->full_name());

+ 5 - 6
Cpp/Platform/Rpc/RpcClientTest.cc

@@ -1,4 +1,3 @@
-#include <boost/threadpool.hpp>
 #include <gtest/gtest.h>
 #include "Rpc/RpcClient.h"
 #include "Thread/CountBarrier.h"
@@ -44,8 +43,8 @@ public:
 		{
 			return;
 		}
-		auto meta = std::make_shared<RpcMeta>();
-		auto message = std::make_shared<std::string>();
+		auto meta = boost::make_shared<RpcMeta>();
+		auto message = boost::make_shared<std::string>();
 		RecvMeta(meta, message);
 	}
 
@@ -59,9 +58,9 @@ public:
 		EchoResponse response;
 		response.set_num(num);
 
-		auto responseMessage = std::make_shared<std::string>();
+		auto responseMessage = boost::make_shared<std::string>();
 		response.SerializeToString(responseMessage.get());
-		auto responseMeta = std::make_shared<RpcMeta>();
+		auto responseMeta = boost::make_shared<RpcMeta>();
 		responseMeta->id = meta->id;
 		responseMeta->size = responseMessage->size();
 		SendMeta(responseMeta, responseMessage);
@@ -89,7 +88,7 @@ TEST_F(RpcClientTest, Echo)
 
 	CountBarrier barrier(2);
 	RpcServerTest server(ioServer, globalPort, barrier);
-	auto client = std::make_shared<RpcClient>(ioClient, "127.0.0.1", globalPort);
+	auto client = boost::make_shared<RpcClient>(ioClient, "127.0.0.1", globalPort);
 	EchoService_Stub service(client.get());
 
 	boost::threadpool::fifo_pool threadPool(2);

+ 24 - 19
Cpp/Platform/Rpc/RpcCommunicatorTest.cc

@@ -1,13 +1,14 @@
 #include <boost/asio.hpp>
-#include <boost/threadpool.hpp>
-#include <memory>
+#include <boost/shared_ptr.hpp>
+#include <boost/make_shared.hpp>
 #include <gtest/gtest.h>
 #include "Rpc/RpcCommunicator.h"
 #include "Thread/CountBarrier.h"
+#include "Log/Log.h"
 
 namespace Egametang {
 
-static int globalPort = 10001;
+static int globalPort = 11111;
 
 class RpcServerTest: public RpcCommunicator
 {
@@ -41,8 +42,8 @@ public:
 			return;
 		}
 
-		auto meta = std::make_shared<RpcMeta>();
-		auto message = std::make_shared<std::string>();
+		auto meta = boost::make_shared<RpcMeta>();
+		auto message = boost::make_shared<std::string>();
 		RecvMeta(meta, message);
 	}
 
@@ -62,8 +63,8 @@ public:
 		recvMessage = *message;
 		recvMeta = *meta;
 
-		auto responseMeta = std::make_shared<RpcMeta>();
-		auto response_message = std::make_shared<std::string>(
+		auto responseMeta = boost::make_shared<RpcMeta>();
+		auto response_message = boost::make_shared<std::string>(
 				"response test rpc communicator string");
 		responseMeta->size = response_message->size();
 		responseMeta->method = 123456;
@@ -81,8 +82,7 @@ public:
 	RpcMeta recvMeta;
 
 public:
-	RpcClientTest(boost::asio::io_service& ioService, int port,
-			CountBarrier& barrier):
+	RpcClientTest(boost::asio::io_service& ioService, int port, CountBarrier& barrier):
 		RpcCommunicator(ioService), barrier(barrier)
 	{
 		boost::asio::ip::address address;
@@ -107,18 +107,19 @@ public:
 	{
 		if (err)
 		{
+			LOG(INFO) << "async connect error: " << err.message();
 			return;
 		}
 
-		auto sendMeta = std::make_shared<RpcMeta>();
-		auto sendMessage = std::make_shared<std::string>(
+		auto sendMeta = boost::make_shared<RpcMeta>();
+		auto sendMessage = boost::make_shared<std::string>(
 				"send test rpc communicator string");
 		sendMeta->size = sendMessage->size();
 		sendMeta->method = 654321;
 		SendMeta(sendMeta, sendMessage);
 
-		auto meta = std::make_shared<RpcMeta>();
-		auto message = std::make_shared<std::string>();
+		auto meta = boost::make_shared<RpcMeta>();
+		auto message = boost::make_shared<std::string>();
 		RecvMeta(meta, message);
 	}
 
@@ -139,21 +140,24 @@ TEST_F(RpcCommunicatorTest, SendAndRecvString)
 {
 	boost::asio::io_service ioServer;
 	boost::asio::io_service ioClient;
+
 	CountBarrier barrier(2);
+
 	RpcServerTest rpcServer(ioServer, globalPort, barrier);
-	RpcClientTest rpcClient(ioClient, globalPort, barrier);
+	boost::thread serverThread(boost::bind(&RpcServerTest::Start, &rpcServer));
 
-	boost::threadpool::fifo_pool threadPool(2);
-	threadPool.schedule(boost::bind(&RpcServerTest::Start, &rpcServer));
+	boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
 
-	boost::this_thread::sleep(boost::posix_time::milliseconds(500));
-	threadPool.schedule(boost::bind(&RpcClientTest::Start, &rpcClient));
+	RpcClientTest rpcClient(ioClient, globalPort, barrier);
+	boost::thread clientThread(boost::bind(&RpcClientTest::Start, &rpcClient));
 	barrier.Wait();
-	threadPool.wait();
 
 	ioClient.post(boost::bind(&boost::asio::io_service::stop, &ioClient));
 	ioServer.post(boost::bind(&boost::asio::io_service::stop, &ioServer));
 
+	serverThread.join();
+	clientThread.join();
+
 	ASSERT_EQ(std::string("send test rpc communicator string"), rpcServer.recvMessage);
 	ASSERT_EQ(rpcServer.recvMeta.size, rpcServer.recvMessage.size());
 	ASSERT_EQ(654321U, rpcServer.recvMeta.method);
@@ -169,5 +173,6 @@ TEST_F(RpcCommunicatorTest, SendAndRecvString)
 int main(int argc, char* argv[])
 {
 	testing::InitGoogleTest(&argc, argv);
+	Egametang::Log::Init(argv[0]);
 	return RUN_ALL_TESTS();
 }

+ 13 - 12
Cpp/Platform/Rpc/RpcServer.cc

@@ -1,6 +1,7 @@
 #include <boost/bind.hpp>
-#include <memory>
+#include <boost/shared_ptr.hpp>
 #include <boost/asio.hpp>
+#include <boost/make_shared.hpp>
 #include <google/protobuf/service.h>
 #include <google/protobuf/descriptor.h>
 #include "Base/Marcos.h"
@@ -14,7 +15,7 @@ namespace Egametang {
 
 RpcServer::RpcServer(boost::asio::io_service& service, int port):
 		ioService(service), acceptor(ioService),
-		threadPool(1), sessions(),
+		sessions(),
 		methods()
 {
 	boost::asio::ip::address address;
@@ -24,7 +25,7 @@ RpcServer::RpcServer(boost::asio::io_service& service, int port):
 	acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
 	acceptor.bind(endpoint);
 	acceptor.listen();
-	auto newSession = std::make_shared<RpcSession>(ioService, *this);
+	auto newSession = boost::make_shared<RpcSession>(ioService, *this);
 	acceptor.async_accept(newSession->Socket(),
 			boost::bind(&RpcServer::OnAsyncAccept, this,
 					newSession, boost::asio::placeholders::error));
@@ -32,7 +33,6 @@ RpcServer::RpcServer(boost::asio::io_service& service, int port):
 
 RpcServer::~RpcServer()
 {
-	threadPool.wait();
 	acceptor.close();
 }
 
@@ -44,7 +44,7 @@ void RpcServer::OnAsyncAccept(RpcSessionPtr session, const boost::system::error_
 	}
 	session->Start();
 	sessions.insert(session);
-	auto newSession = std::make_shared<RpcSession>(ioService, *this);
+	auto newSession = boost::make_shared<RpcSession>(ioService, *this);
 	acceptor.async_accept(newSession->Socket(),
 			boost::bind(&RpcServer::OnAsyncAccept, this,
 					newSession, boost::asio::placeholders::error));
@@ -64,16 +64,17 @@ void RpcServer::RunService(
 	MethodInfoPtr methodInfo = methods[meta->method];
 
 	auto responseHandler =
-			std::make_shared<ResponseHandler>(meta, message, methodInfo, messageHandler);
+			boost::make_shared<ResponseHandler>(meta, message, methodInfo, messageHandler);
 
 	google::protobuf::Closure* done = google::protobuf::NewCallback(
 			this, &RpcServer::OnCallMethod, session, responseHandler);
 
-	threadPool.schedule(
-			boost::bind(&google::protobuf::Service::CallMethod, methodInfo->GetService(),
-					&responseHandler->Method(), (google::protobuf::RpcController*)(nullptr),
-					responseHandler->Request(), responseHandler->Response(),
-					done));
+	methodInfo->GetService()->CallMethod(
+		&responseHandler->Method(), 
+		(google::protobuf::RpcController*)(nullptr),
+		responseHandler->Request(),
+		responseHandler->Response(),
+		done);
 }
 
 void RpcServer::Register(ProtobufServicePtr service)
@@ -85,7 +86,7 @@ void RpcServer::Register(ProtobufServicePtr service)
 		const google::protobuf::MethodDescriptor* methodDescriptor =
 				serviceDescriptor->method(i);
 		std::size_t methodHash = stringHash(methodDescriptor->full_name());
-		auto methodInfo = std::make_shared<MethodInfo>(service, methodDescriptor);
+		auto methodInfo = boost::make_shared<MethodInfo>(service, methodDescriptor);
 		methods[methodHash] = methodInfo;
 	}
 }

+ 5 - 7
Cpp/Platform/Rpc/RpcServer.h

@@ -2,28 +2,26 @@
 #define RPC_RPCSERVER_H
 
 #include <boost/bind.hpp>
-#include <unordered_set>
-#include <unordered_map>
+#include <boost/unordered_set.hpp>
+#include <boost/unordered_map.hpp>
 #include <boost/asio.hpp>
 #include <boost/enable_shared_from_this.hpp>
-#include <boost/threadpool.hpp>
 #include <google/protobuf/service.h>
 #include "Base/Marcos.h"
 #include "Rpc/Typedef.h"
 
 namespace Egametang {
 
-typedef std::unordered_set<RpcSessionPtr> RpcSessionSet;
-typedef std::unordered_map<std::size_t, MethodInfoPtr> MethodMap;
-
 class RpcServer: public boost::noncopyable, public boost::enable_shared_from_this<RpcServer>
 {
 private:
+	typedef boost::unordered_set<RpcSessionPtr> RpcSessionSet;
+	typedef boost::unordered_map<std::size_t, MethodInfoPtr> MethodMap;
+
 	friend class RpcServerTest;
 
 	boost::asio::io_service& ioService;
 	boost::asio::ip::tcp::acceptor acceptor;
-	boost::threadpool::fifo_pool threadPool;
 	RpcSessionSet sessions;
 	MethodMap methods;
 

+ 4 - 4
Cpp/Platform/Rpc/RpcServerTest.cc

@@ -1,5 +1,5 @@
 #include <boost/bind.hpp>
-#include <memory>
+#include <boost/shared_ptr.hpp>
 #include <boost/asio.hpp>
 #include <boost/threadpool.hpp>
 #include <gtest/gtest.h>
@@ -54,14 +54,14 @@ TEST_F(RpcServerTest, ClientAndServer)
 
 	boost::threadpool::fifo_pool threadPool(2);
 
-	auto echoSevice = std::make_shared<MyEcho>();
+	auto echoSevice = boost::make_shared<MyEcho>();
 
-	auto server = std::make_shared<RpcServer>(ioServer, globalPort);
+	auto server = boost::make_shared<RpcServer>(ioServer, globalPort);
 	// 注册service
 	server->Register(echoSevice);
 	ASSERT_EQ(1U, GetMethodMap(server).size());
 
-	auto client = std::make_shared<RpcClient>(ioClient, "127.0.0.1", globalPort);
+	auto client = boost::make_shared<RpcClient>(ioClient, "127.0.0.1", globalPort);
 	EchoService_Stub service(client.get());
 
 	// 定义消息

+ 4 - 3
Cpp/Platform/Rpc/RpcSession.cc

@@ -1,5 +1,6 @@
-#include <memory>
+#include <boost/shared_ptr.hpp>
 #include <boost/bind.hpp>
+#include <boost/make_shared.hpp>
 #include "Rpc/RpcSession.h"
 #include "Rpc/RpcServer.h"
 
@@ -30,8 +31,8 @@ void RpcSession::OnSendMessage(RpcMetaPtr meta, StringPtr message)
 
 void RpcSession::Start()
 {
-	auto meta = std::make_shared<RpcMeta>();
-	auto message = std::make_shared<std::string>();
+	auto meta = boost::make_shared<RpcMeta>();
+	auto message = boost::make_shared<std::string>();
 	RecvMeta(meta, message);
 }
 

+ 1 - 1
Cpp/Platform/Rpc/RpcSession.h

@@ -11,7 +11,7 @@ namespace Egametang {
 
 class RpcServer;
 
-class RpcSession: public RpcCommunicator, public std::enable_shared_from_this<RpcSession>
+class RpcSession: public RpcCommunicator, public boost::enable_shared_from_this<RpcSession>
 {
 private:
 	RpcServer& rpcServer;

+ 10 - 9
Cpp/Platform/Rpc/Typedef.h

@@ -1,8 +1,9 @@
 #ifndef RPC_TYPEDEF_H
 #define RPC_TYPEDEF_H
 
-#include <memory>
 #include <boost/bind.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/function.hpp>
 #include "Base/Typedef.h"
 
 namespace Egametang {
@@ -15,15 +16,15 @@ class MethodInfo;
 class RpcMeta;
 class ResponseHandler;
 
-typedef std::shared_ptr<RpcServer> 	                RpcServerPtr;
-typedef std::shared_ptr<RpcSession>                 RpcSessionPtr;
-typedef std::shared_ptr<RpcClient>                  RpcClientPtr;
-typedef std::shared_ptr<MethodInfo>                 MethodInfoPtr;
-typedef std::shared_ptr<RpcMeta> 	                RpcMetaPtr;
-typedef std::shared_ptr<RequestHandler>             RequestHandlerPtr;
-typedef std::shared_ptr<ResponseHandler>            ResponseHandlerPtr;
+typedef boost::shared_ptr<RpcServer> 	            RpcServerPtr;
+typedef boost::shared_ptr<RpcSession>               RpcSessionPtr;
+typedef boost::shared_ptr<RpcClient>                RpcClientPtr;
+typedef boost::shared_ptr<MethodInfo>               MethodInfoPtr;
+typedef boost::shared_ptr<RpcMeta> 	                RpcMetaPtr;
+typedef boost::shared_ptr<RequestHandler>           RequestHandlerPtr;
+typedef boost::shared_ptr<ResponseHandler>          ResponseHandlerPtr;
 
-typedef std::function<void (RpcMetaPtr, StringPtr)> MessageHandler;
+typedef boost::function<void (RpcMetaPtr, StringPtr)> MessageHandler;
 
 } // namespace Egametang
 

+ 0 - 2
Cpp/Platform/Thread/CMakeLists.txt

@@ -8,11 +8,9 @@ SET(ThreadSrc
 ADD_LIBRARY(Thread ${ThreadSrc})
 SET_PROPERTY(TARGET Thread PROPERTY FOLDER "Platform")
 
-ADD_EXECUTABLE(ThreadPoolTest ThreadPoolTest.cc)
 ADD_EXECUTABLE(CountBarrierTest CountBarrierTest.cc)
 
 SET(Tests 
-	ThreadPoolTest 
 	CountBarrierTest
 )
 

+ 18 - 28
Cpp/Platform/Thread/CountBarrierTest.cc

@@ -1,33 +1,18 @@
 #include <boost/detail/atomic_count.hpp>
 #include <boost/date_time.hpp>
-#include <boost/threadpool.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/make_shared.hpp>
+#include <boost/ref.hpp>
+#include <boost/foreach.hpp>
+#include <boost/bind.hpp>
 #include <gtest/gtest.h>
+#include "Base/Marcos.h"
 #include "Thread/CountBarrier.h"
 
 namespace Egametang {
 
 class CountBarrierTest: public testing::Test
 {
-protected:
-	boost::detail::atomic_count count;
-public:
-	CountBarrierTest(): count(0)
-	{
-	}
-	virtual ~CountBarrierTest()
-	{
-	}
-
-	void Wait(CountBarrier& barrier)
-	{
-		barrier.Wait();
-	}
-	void Signal(CountBarrier& barrier)
-	{
-		boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
-		++count;
-		barrier.Signal();
-	}
 };
 
 TEST_F(CountBarrierTest, Count)
@@ -36,20 +21,25 @@ TEST_F(CountBarrierTest, Count)
 	ASSERT_EQ(10, barrier.Count());
 }
 
+static void Signal(CountBarrier& barrier, boost::detail::atomic_count& count)
+{
+	boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
+	++count;
+	barrier.Signal();
+}
+
 TEST_F(CountBarrierTest, WaitAndSignal)
 {
+	boost::detail::atomic_count count(0);
+
 	CountBarrier barrier(10);
-	boost::threadpool::fifo_pool pool(10);
+	std::vector< boost::shared_ptr<boost::thread> > v(10);
 	for (int i = 0; i < 10; ++i)
 	{
-		pool.schedule(
-				boost::bind(&CountBarrierTest::Signal,
-						this, std::ref(barrier)));
+		v[i].reset(new boost::thread(boost::bind(&Signal, boost::ref(barrier), boost::ref(count))));
 	}
-	ASSERT_EQ(0, this->count);
 	barrier.Wait();
-	ASSERT_EQ(10, this->count);
-	pool.wait();
+	ASSERT_EQ(10, count);
 }
 
 } // namespace Egametang

+ 0 - 39
Cpp/Platform/Thread/ThreadPoolTest.cc

@@ -1,39 +0,0 @@
-#include <boost/bind.hpp>
-#include <boost/threadpool.hpp>
-#include <gtest/gtest.h>
-
-namespace Egametang {
-
-class ThreadPoolTest: public testing::Test
-{
-};
-
-static void Max(int a, int b, int* z)
-{
-	*z = a > b? a : b;
-}
-
-TEST_F(ThreadPoolTest, Test1)
-{
-	boost::threadpool::fifo_pool pool(10);
-	std::vector<int> x(100, 8);
-	std::vector<int> y(100, 9);
-	std::vector<int> z(100, 0);
-	for (int i = 0; i < 100; ++i)
-	{
-		pool.schedule(boost::bind(&Max, x[i], y[i], &z[i]));
-	}
-	pool.wait();
-	for (int i = 0; i < 100; ++i)
-	{
-		ASSERT_EQ(9, z[i]);
-	}
-}
-
-} // namespace Egametang
-
-int main(int argc, char* argv[])
-{
-	testing::InitGoogleTest(&argc, argv);
-	return RUN_ALL_TESTS();
-}

+ 0 - 28
Cpp/ThirdParty/boost/threadpool.hpp

@@ -1,28 +0,0 @@
-/*! \file
-* \brief Main include.
-*
-* This is the only file you have to include in order to use the 
-* complete threadpool library.
-*
-* Copyright (c) 2005-2007 Philipp Henkel
-*
-* Use, modification, and distribution are  subject to the
-* Boost Software License, Version 1.0. (See accompanying  file
-* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-* http://threadpool.sourceforge.net
-*
-*/
-
-#ifndef THREADPOOL_HPP_INCLUDED
-#define THREADPOOL_HPP_INCLUDED
-
-#include "./threadpool/future.hpp"
-#include "./threadpool/pool.hpp"
-
-#include "./threadpool/pool_adaptors.hpp"
-#include "./threadpool/task_adaptors.hpp"
-
-
-#endif // THREADPOOL_HPP_INCLUDED
-

+ 0 - 215
Cpp/ThirdParty/boost/threadpool/detail/future.hpp

@@ -1,215 +0,0 @@
-/*! \file
-* \brief TODO.
-*
-* TODO. 
-*
-* Copyright (c) 2005-2007 Philipp Henkel
-*
-* Use, modification, and distribution are  subject to the
-* Boost Software License, Version 1.0. (See accompanying  file
-* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-* http://threadpool.sourceforge.net
-*
-*/
-
-
-#ifndef THREADPOOL_DETAIL_FUTURE_IMPL_HPP_INCLUDED
-#define THREADPOOL_DETAIL_FUTURE_IMPL_HPP_INCLUDED
-
-
-#include "locking_ptr.hpp"
-
-#include <boost/smart_ptr.hpp>
-#include <boost/optional.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/condition.hpp>
-#include <boost/thread/xtime.hpp>
-#include <boost/utility/result_of.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/type_traits.hpp>
-
-namespace boost { namespace threadpool { namespace detail 
-{
-
-template<class Result> 
-class future_impl
-{
-public:
-  typedef Result const & result_type; //!< Indicates the functor's result type.
-
-  typedef Result future_result_type; //!< Indicates the future's result type.
-  typedef future_impl<future_result_type> future_type;
-
-private:
-    volatile bool m_ready;
-    volatile future_result_type m_result;
-
-    mutable mutex m_monitor;
-    mutable condition m_condition_ready;	
-
-    volatile bool m_is_cancelled;
-    volatile bool m_executing;
-
-public:
-
-
-public:
-
-  future_impl()
-  : m_ready(false)
-  , m_is_cancelled(false)
-  {
-  }
-
-  bool ready() const volatile
-  {
-    return m_ready; 
-  }
-
-  void wait() const volatile
-  {
-    const future_type* self = const_cast<const future_type*>(this);
-    mutex::scoped_lock lock(self->m_monitor);
-
-    while(!m_ready)
-    {
-      self->m_condition_ready.wait(lock);
-    }
-  }
-
-
-  bool timed_wait(boost::xtime const & timestamp) const
-  {
-    const future_type* self = const_cast<const future_type*>(this);
-    mutex::scoped_lock lock(self->m_monitor);
-
-    while(!m_ready)
-    {
-      if(!self->m_condition_ready.timed_wait(lock, timestamp)) return false;
-    }
-
-    return true;
-  }
-
-
-  result_type operator()() const volatile
-  {
-    wait();
-/*
-    if( throw_exception_ != 0 )
-    {
-      throw_exception_( this );
-    }
-*/
- 
-    return *(const_cast<const future_result_type*>(&m_result));
-  }
-
-
-  void set_value(future_result_type const & r) volatile
-  {
-    locking_ptr<future_type, mutex> lockedThis(*this, m_monitor);
-    if(!m_ready && !m_is_cancelled)
-    {
-      lockedThis->m_result = r;
-      lockedThis->m_ready = true;
-      lockedThis->m_condition_ready.notify_all();
-    }
-  }
-/*
-  template<class E> void set_exception() // throw()
-  {
-    m_impl->template set_exception<E>();
-  }
-
-  template<class E> void set_exception( char const * what ) // throw()
-  {
-    m_impl->template set_exception<E>( what );
-  }
-  */
-
-
-   bool cancel() volatile
-   {
-     if(!m_ready || m_executing)
-     {
-        m_is_cancelled = true;
-        return true;
-     }
-     else
-     {
-       return false;
-     }
-   }
-
-
-   bool is_cancelled() const volatile
-   {
-     return m_is_cancelled;
-   }
-
-
-   void set_execution_status(bool executing) volatile
-   {
-     m_executing = executing;
-   }
-};
-
-
-template<
-  template <typename> class Future,
-  typename Function
->
-class future_impl_task_func
-{
-
-public:
-  typedef void result_type;                         //!< Indicates the functor's result type.
-
-  typedef Function function_type;                   //!< Indicates the function's type.
-  typedef typename result_of<function_type()>::type future_result_type; //!< Indicates the future's result type.
-  typedef Future<future_result_type> future_type;   //!< Indicates the future's type.
-
-  // The task is required to be a nullary function.
-  BOOST_STATIC_ASSERT(function_traits<function_type()>::arity == 0);
-
-  // The task function's result type is required not to be void.
-  BOOST_STATIC_ASSERT(!is_void<future_result_type>::value);
-
-private:
-  function_type             m_function;
-  shared_ptr<future_type>   m_future;
-
-public:
-  future_impl_task_func(function_type const & function, shared_ptr<future_type> const & future)
-  : m_function(function)
-  , m_future(future)
-  {
-  }
-
-  void operator()()
-  {
-    if(m_function)
-    {
-      m_future->set_execution_status(true);
-      if(!m_future->is_cancelled())
-      {
-        // TODO future exeception handling 
-        m_future->set_value(m_function());
-      }
-      m_future->set_execution_status(false); // TODO consider exceptions
-    }
-  }
-
-};
-
-
-
-
-
-} } } // namespace boost::threadpool::detail
-
-#endif // THREADPOOL_DETAIL_FUTURE_IMPL_HPP_INCLUDED
-
-

+ 0 - 85
Cpp/ThirdParty/boost/threadpool/detail/locking_ptr.hpp

@@ -1,85 +0,0 @@
-/*! \file
-* \brief The locking_ptr is smart pointer with a scoped locking mechanism.
-*
-* The class is a wrapper for a volatile pointer. It enables synchronized access to the
-* internal pointer by locking the passed mutex.
-* locking_ptr is based on Andrei Alexandrescu's LockingPtr. For more information
-* see article "volatile - Multithreaded Programmer's Best Friend" by A. Alexandrescu.
-*
-*
-* Copyright (c) 2005-2007 Philipp Henkel
-*
-* Use, modification, and distribution are  subject to the
-* Boost Software License, Version 1.0. (See accompanying  file
-* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-* http://threadpool.sourceforge.net
-*
-*/
-
-
-#ifndef THREADPOOL_DETAIL_LOCKING_PTR_HPP_INCLUDED
-#define THREADPOOL_DETAIL_LOCKING_PTR_HPP_INCLUDED
-
-#include <boost/utility.hpp>
-#include <boost/thread/mutex.hpp>
-
-
-namespace boost { namespace threadpool { namespace detail 
-{
-
-/*! \brief  Smart pointer with a scoped locking mechanism.
- *
- * This class is a wrapper for a volatile pointer. It enables synchronized access to the
- * internal pointer by locking the passed mutex.
- */
-  template <typename T, typename Mutex>
-  class locking_ptr 
-  : private noncopyable
-  {
-    T* m_obj;                     //!< The instance pointer. 
-    Mutex & m_mutex;              //!< Mutex is used for scoped locking.
-
-  public:
-    /// Constructor.
-    locking_ptr(volatile T& obj, const volatile Mutex& mtx)
-      : m_obj(const_cast<T*>(&obj))
-      , m_mutex(*const_cast<Mutex*>(&mtx))
-    {   
-      // Lock mutex
-	  m_mutex.lock();
-    }
-
-
-    /// Destructor.
-    ~locking_ptr()
-    { 
-      // Unlock mutex
-      m_mutex.unlock();
-    }
-
-
-    /*! Returns a reference to the stored instance.
-    * \return The instance's reference.
-    */
-    T& operator*() const
-    {    
-      return *m_obj;    
-    }
-
-
-    /*! Returns a pointer to the stored instance.
-    * \return The instance's pointer.
-    */
-    T* operator->() const
-    {   
-      return m_obj;   
-    }
-  };
-
-
-} } } // namespace boost::threadpool::detail
-
-
-#endif // THREADPOOL_DETAIL_LOCKING_PTR_HPP_INCLUDED
-

+ 0 - 453
Cpp/ThirdParty/boost/threadpool/detail/pool_core.hpp

@@ -1,453 +0,0 @@
-/*! \file
-* \brief Thread pool core.
-*
-* This file contains the threadpool's core class: pool<Task, SchedulingPolicy>.
-*
-* Thread pools are a mechanism for asynchronous and parallel processing 
-* within the same process. The pool class provides a convenient way 
-* for dispatching asynchronous tasks as functions objects. The scheduling
-* of these tasks can be easily controlled by using customized schedulers. 
-*
-* Copyright (c) 2005-2007 Philipp Henkel
-*
-* Use, modification, and distribution are  subject to the
-* Boost Software License, Version 1.0. (See accompanying  file
-* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-* http://threadpool.sourceforge.net
-*
-*/
-
-
-#ifndef THREADPOOL_POOL_CORE_HPP_INCLUDED
-#define THREADPOOL_POOL_CORE_HPP_INCLUDED
-
-
-
-
-#include "locking_ptr.hpp"
-#include "worker_thread.hpp"
-
-#include "../task_adaptors.hpp"
-
-#include <boost/thread.hpp>
-#include <boost/thread/exceptions.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/condition.hpp>
-#include <boost/smart_ptr.hpp>
-#include <boost/bind.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/type_traits.hpp>
-
-#include <vector>
-
-
-/// The namespace threadpool contains a thread pool and related utility classes.
-namespace boost { namespace threadpool { namespace detail 
-{
-
-  /*! \brief Thread pool. 
-  *
-  * Thread pools are a mechanism for asynchronous and parallel processing 
-  * within the same process. The pool class provides a convenient way 
-  * for dispatching asynchronous tasks as functions objects. The scheduling
-  * of these tasks can be easily controlled by using customized schedulers. 
-  * A task must not throw an exception.
-  *
-  * A pool_impl is DefaultConstructible and NonCopyable.
-  *
-  * \param Task A function object which implements the operator 'void operator() (void) const'. The operator () is called by the pool to execute the task. Exceptions are ignored.
-  * \param Scheduler A task container which determines how tasks are scheduled. It is guaranteed that this container is accessed only by one thread at a time. The scheduler shall not throw exceptions.
-  *
-  * \remarks The pool class is thread-safe.
-  * 
-  * \see Tasks: task_func, prio_task_func
-  * \see Scheduling policies: fifo_scheduler, lifo_scheduler, prio_scheduler
-  */ 
-  template <
-    typename Task, 
-
-    template <typename> class SchedulingPolicy,
-    template <typename> class SizePolicy,
-    template <typename> class SizePolicyController,
-    template <typename> class ShutdownPolicy
-  > 
-  class pool_core
-  : public enable_shared_from_this< pool_core<Task, SchedulingPolicy, SizePolicy, SizePolicyController, ShutdownPolicy > > 
-  , private noncopyable
-  {
-
-  public: // Type definitions
-    typedef Task task_type;                                 //!< Indicates the task's type.
-    typedef SchedulingPolicy<task_type> scheduler_type;     //!< Indicates the scheduler's type.
-    typedef pool_core<Task, 
-                      SchedulingPolicy, 
-                      SizePolicy,
-                      SizePolicyController,
-                      ShutdownPolicy > pool_type;           //!< Indicates the thread pool's type.
-    typedef SizePolicy<pool_type> size_policy_type;         //!< Indicates the sizer's type.
-    //typedef typename size_policy_type::size_controller size_controller_type;
-
-    typedef SizePolicyController<pool_type> size_controller_type;
-
-//    typedef SizePolicy<pool_type>::size_controller size_controller_type;
-    typedef ShutdownPolicy<pool_type> shutdown_policy_type;//!< Indicates the shutdown policy's type.  
-
-    typedef worker_thread<pool_type> worker_type;
-
-    // The task is required to be a nullary function.
-    BOOST_STATIC_ASSERT(function_traits<task_type()>::arity == 0);
-
-    // The task function's result type is required to be void.
-    BOOST_STATIC_ASSERT(is_void<typename result_of<task_type()>::type >::value);
-
-
-  private:  // Friends 
-    friend class worker_thread<pool_type>;
-
-#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x580)  // Tested with CC: Sun C++ 5.8 Patch 121018-08 2006/12/06
-   friend class SizePolicy;
-   friend class ShutdownPolicy;
-#else
-   friend class SizePolicy<pool_type>;
-   friend class ShutdownPolicy<pool_type>;
-#endif
-
-  private: // The following members may be accessed by _multiple_ threads at the same time:
-    volatile size_t m_worker_count;	
-    volatile size_t m_target_worker_count;	
-    volatile size_t m_active_worker_count;
-      
-
-
-  private: // The following members are accessed only by _one_ thread at the same time:
-    scheduler_type  m_scheduler;
-    scoped_ptr<size_policy_type> m_size_policy; // is never null
-    
-    bool  m_terminate_all_workers;								// Indicates if termination of all workers was triggered.
-    std::vector<shared_ptr<worker_type> > m_terminated_workers; // List of workers which are terminated but not fully destructed.
-    
-  private: // The following members are implemented thread-safe:
-    mutable recursive_mutex  m_monitor;
-    mutable condition m_worker_idle_or_terminated_event;	// A worker is idle or was terminated.
-    mutable condition m_task_or_terminate_workers_event;  // Task is available OR total worker count should be reduced.
-
-  public:
-    /// Constructor.
-    pool_core()
-      : m_worker_count(0) 
-      , m_target_worker_count(0)
-      , m_active_worker_count(0)
-      , m_terminate_all_workers(false)
-    {
-      pool_type volatile & self_ref = *this;
-      m_size_policy.reset(new size_policy_type(self_ref));
-
-      m_scheduler.clear();
-    }
-
-
-    /// Destructor.
-    ~pool_core()
-    {
-    }
-
-    /*! Gets the size controller which manages the number of threads in the pool. 
-    * \return The size controller.
-    * \see SizePolicy
-    */
-    size_controller_type size_controller()
-    {
-      return size_controller_type(*m_size_policy, this->shared_from_this());
-    }
-
-    /*! Gets the number of threads in the pool.
-    * \return The number of threads.
-    */
-    size_t size()	const volatile
-    {
-      return m_worker_count;
-    }
-
-// TODO is only called once
-    void shutdown()
-    {
-      ShutdownPolicy<pool_type>::shutdown(*this);
-    }
-
-    /*! Schedules a task for asynchronous execution. The task will be executed once only.
-    * \param task The task function object. It should not throw execeptions.
-    * \return true, if the task could be scheduled and false otherwise. 
-    */  
-    bool schedule(task_type const & task) volatile
-    {	
-      locking_ptr<pool_type, recursive_mutex> lockedThis(*this, m_monitor); 
-      
-      if(lockedThis->m_scheduler.push(task))
-      {
-        lockedThis->m_task_or_terminate_workers_event.notify_one();
-        return true;
-      }
-      else
-      {
-        return false;
-      }
-    }	
-
-
-    /*! Returns the number of tasks which are currently executed.
-    * \return The number of active tasks. 
-    */  
-    size_t active() const volatile
-    {
-      return m_active_worker_count;
-    }
-
-
-    /*! Returns the number of tasks which are ready for execution.    
-    * \return The number of pending tasks. 
-    */  
-    size_t pending() const volatile
-    {
-      locking_ptr<const pool_type, recursive_mutex> lockedThis(*this, m_monitor);
-      return lockedThis->m_scheduler.size();
-    }
-
-
-    /*! Removes all pending tasks from the pool's scheduler.
-    */  
-    void clear() volatile
-    { 
-      locking_ptr<pool_type, recursive_mutex> lockedThis(*this, m_monitor);
-      lockedThis->m_scheduler.clear();
-    }    
-
-
-    /*! Indicates that there are no tasks pending. 
-    * \return true if there are no tasks ready for execution.	
-    * \remarks This function is more efficient that the check 'pending() == 0'.
-    */   
-    bool empty() const volatile
-    {
-      locking_ptr<const pool_type, recursive_mutex> lockedThis(*this, m_monitor);
-      return lockedThis->m_scheduler.empty();
-    }	
-
-
-    /*! The current thread of execution is blocked until the sum of all active
-    *  and pending tasks is equal or less than a given threshold. 
-    * \param task_threshold The maximum number of tasks in pool and scheduler.
-    */     
-    void wait(size_t const task_threshold = 0) const volatile
-    {
-      const pool_type* self = const_cast<const pool_type*>(this);
-      recursive_mutex::scoped_lock lock(self->m_monitor);
-
-      if(0 == task_threshold)
-      {
-        while(0 != self->m_active_worker_count || !self->m_scheduler.empty())
-        { 
-          self->m_worker_idle_or_terminated_event.wait(lock);
-        }
-      }
-      else
-      {
-        while(task_threshold < self->m_active_worker_count + self->m_scheduler.size())
-        { 
-          self->m_worker_idle_or_terminated_event.wait(lock);
-        }
-      }
-    }	
-
-    /*! The current thread of execution is blocked until the timestamp is met
-    * or the sum of all active and pending tasks is equal or less 
-    * than a given threshold.  
-    * \param timestamp The time when function returns at the latest.
-    * \param task_threshold The maximum number of tasks in pool and scheduler.
-    * \return true if the task sum is equal or less than the threshold, false otherwise.
-    */       
-    bool wait(xtime const & timestamp, size_t const task_threshold = 0) const volatile
-    {
-      const pool_type* self = const_cast<const pool_type*>(this);
-      recursive_mutex::scoped_lock lock(self->m_monitor);
-
-      if(0 == task_threshold)
-      {
-        while(0 != self->m_active_worker_count || !self->m_scheduler.empty())
-        { 
-          if(!self->m_worker_idle_or_terminated_event.timed_wait(lock, timestamp)) return false;
-        }
-      }
-      else
-      {
-        while(task_threshold < self->m_active_worker_count + self->m_scheduler.size())
-        { 
-          if(!self->m_worker_idle_or_terminated_event.timed_wait(lock, timestamp)) return false;
-        }
-      }
-
-      return true;
-    }
-
-
-  private:	
-
-
-    void terminate_all_workers(bool const wait) volatile
-    {
-      pool_type* self = const_cast<pool_type*>(this);
-      recursive_mutex::scoped_lock lock(self->m_monitor);
-
-      self->m_terminate_all_workers = true;
-
-      m_target_worker_count = 0;
-      self->m_task_or_terminate_workers_event.notify_all();
-
-      if(wait)
-      {
-        while(m_active_worker_count > 0)
-        {
-          self->m_worker_idle_or_terminated_event.wait(lock);
-        }
-
-        for(typename std::vector<shared_ptr<worker_type> >::iterator it = self->m_terminated_workers.begin();
-          it != self->m_terminated_workers.end();
-          ++it)
-        {
-          (*it)->join();
-        }
-        self->m_terminated_workers.clear();
-      }
-    }
-
-
-    /*! Changes the number of worker threads in the pool. The resizing 
-    *  is handled by the SizePolicy.
-    * \param threads The new number of worker threads.
-    * \return true, if pool will be resized and false if not. 
-    */
-    bool resize(size_t const worker_count) volatile
-    {
-      locking_ptr<pool_type, recursive_mutex> lockedThis(*this, m_monitor); 
-
-      if(!m_terminate_all_workers)
-      {
-        m_target_worker_count = worker_count;
-      }
-      else
-      { 
-        return false;
-      }
-
-
-      if(m_worker_count <= m_target_worker_count)
-      { // increase worker count
-        while(m_worker_count < m_target_worker_count)
-        {
-          try
-          {
-            worker_thread<pool_type>::create_and_attach(lockedThis->shared_from_this());
-            m_worker_count++;
-            m_active_worker_count++;	
-          }
-          catch(thread_resource_error)
-          {
-            return false;
-          }
-        }
-      }
-      else
-      { // decrease worker count
-        lockedThis->m_task_or_terminate_workers_event.notify_all();   // TODO: Optimize number of notified workers
-      }
-
-      return true;
-    }
-
-
-    // worker died with unhandled exception
-    void worker_died_unexpectedly(shared_ptr<worker_type> worker) volatile
-    {
-      locking_ptr<pool_type, recursive_mutex> lockedThis(*this, m_monitor);
-
-      m_worker_count--;
-      m_active_worker_count--;
-      lockedThis->m_worker_idle_or_terminated_event.notify_all();	
-
-      if(m_terminate_all_workers)
-      {
-        lockedThis->m_terminated_workers.push_back(worker);
-      }
-      else
-      {
-        lockedThis->m_size_policy->worker_died_unexpectedly(m_worker_count);
-      }
-    }
-
-    void worker_destructed(shared_ptr<worker_type> worker) volatile
-    {
-      locking_ptr<pool_type, recursive_mutex> lockedThis(*this, m_monitor);
-      m_worker_count--;
-      m_active_worker_count--;
-      lockedThis->m_worker_idle_or_terminated_event.notify_all();	
-
-      if(m_terminate_all_workers)
-      {
-        lockedThis->m_terminated_workers.push_back(worker);
-      }
-    }
-
-
-    bool execute_task() volatile
-    {
-      function0<void> task;
-
-      { // fetch task
-        pool_type* lockedThis = const_cast<pool_type*>(this);
-        recursive_mutex::scoped_lock lock(lockedThis->m_monitor);
-
-        // decrease number of threads if necessary
-        if(m_worker_count > m_target_worker_count)
-        {	
-          return false;	// terminate worker
-        }
-
-
-        // wait for tasks
-        while(lockedThis->m_scheduler.empty())
-        {	
-          // decrease number of workers if necessary
-          if(m_worker_count > m_target_worker_count)
-          {	
-            return false;	// terminate worker
-          }
-          else
-          {
-            m_active_worker_count--;
-            lockedThis->m_worker_idle_or_terminated_event.notify_all();	
-            lockedThis->m_task_or_terminate_workers_event.wait(lock);
-            m_active_worker_count++;
-          }
-        }
-
-        task = lockedThis->m_scheduler.top();
-        lockedThis->m_scheduler.pop();
-      }
-
-      // call task function
-      if(task)
-      {
-        task();
-      }
- 
-      //guard->disable();
-      return true;
-    }
-  };
-
-
-
-
-} } } // namespace boost::threadpool::detail
-
-#endif // THREADPOOL_POOL_CORE_HPP_INCLUDED

+ 0 - 65
Cpp/ThirdParty/boost/threadpool/detail/scope_guard.hpp

@@ -1,65 +0,0 @@
-/*! \file
-* \brief TODO.
-*
-* TODO. 
-*
-* Copyright (c) 2005-2007 Philipp Henkel
-*
-* Use, modification, and distribution are  subject to the
-* Boost Software License, Version 1.0. (See accompanying  file
-* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-* http://threadpool.sourceforge.net
-*
-*/
-
-
-#ifndef THREADPOOL_DETAIL_SCOPE_GUARD_HPP_INCLUDED
-#define THREADPOOL_DETAIL_SCOPE_GUARD_HPP_INCLUDED
-
-
-
-#include <boost/function.hpp>
-
-
-namespace boost { namespace threadpool { namespace detail 
-{
-
-// TODO documentation
-class scope_guard
-: private boost::noncopyable
-{
-	function0<void> const m_function;
-	bool                  m_is_active;
-
-public:
-	scope_guard(function0<void> const & call_on_exit)
-	: m_function(call_on_exit)
-	, m_is_active(true)
-	{
-	}
-
-	~scope_guard()
-	{
-		if(m_is_active && m_function)
-		{
-			m_function();
-		}
-	}
-
-	void disable()
-	{
-		m_is_active = false;
-	}
-};
-
-
-
-
-
-
-} } } // namespace boost::threadpool::detail
-
-#endif // THREADPOOL_DETAIL_SCOPE_GUARD_HPP_INCLUDED
-
-

+ 0 - 115
Cpp/ThirdParty/boost/threadpool/detail/worker_thread.hpp

@@ -1,115 +0,0 @@
-/*! \file
-* \brief Thread pool worker.
-*
-* The worker thread instance is attached to a pool 
-* and executes tasks of this pool. 
-*
-* Copyright (c) 2005-2007 Philipp Henkel
-*
-* Use, modification, and distribution are  subject to the
-* Boost Software License, Version 1.0. (See accompanying  file
-* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-* http://threadpool.sourceforge.net
-*
-*/
-
-#ifndef THREADPOOL_DETAIL_WORKER_THREAD_HPP_INCLUDED
-#define THREADPOOL_DETAIL_WORKER_THREAD_HPP_INCLUDED
-
-
-#include "scope_guard.hpp"
-
-#include <boost/smart_ptr.hpp>
-#include <boost/thread.hpp>
-#include <boost/thread/exceptions.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/bind.hpp>
-
-
-namespace boost { namespace threadpool { namespace detail 
-{
-
-  /*! \brief Thread pool worker. 
-  *
-  * A worker_thread represents a thread of execution. The worker is attached to a 
-  * thread pool and processes tasks of that pool. The lifetime of the worker and its 
-  * internal boost::thread is managed automatically.
-  *
-  * This class is a helper class and cannot be constructed or accessed directly.
-  * 
-  * \see pool_core
-  */ 
-  template <typename Pool>
-  class worker_thread
-  : public enable_shared_from_this< worker_thread<Pool> > 
-  , private noncopyable
-  {
-  public:
-    typedef Pool pool_type;         	   //!< Indicates the pool's type.
-
-  private:
-    shared_ptr<pool_type>      m_pool;     //!< Pointer to the pool which created the worker.
-    shared_ptr<boost::thread>  m_thread;   //!< Pointer to the thread which executes the run loop.
-
-    
-    /*! Constructs a new worker. 
-    * \param pool Pointer to it's parent pool.
-    * \see function create_and_attach
-    */
-    worker_thread(shared_ptr<pool_type> const & pool)
-    : m_pool(pool)
-    {
-      assert(pool);
-    }
-
-	
-	/*! Notifies that an exception occurred in the run loop.
-	*/
-	void died_unexpectedly()
-	{
-		m_pool->worker_died_unexpectedly(this->shared_from_this());
-	}
-
-
-  public:
-	  /*! Executes pool's tasks sequentially.
-	  */
-	  void run()
-	  { 
-		  scope_guard notify_exception(bind(&worker_thread::died_unexpectedly, this));
-
-		  while(m_pool->execute_task()) {}
-
-		  notify_exception.disable();
-		  m_pool->worker_destructed(this->shared_from_this());
-	  }
-
-
-	  /*! Joins the worker's thread.
-	  */
-	  void join()
-	  {
-		  m_thread->join();
-	  }
-
-
-	  /*! Constructs a new worker thread and attaches it to the pool.
-	  * \param pool Pointer to the pool.
-	  */
-	  static void create_and_attach(shared_ptr<pool_type> const & pool)
-	  {
-		  shared_ptr<worker_thread> worker(new worker_thread(pool));
-		  if(worker)
-		  {
-			  worker->m_thread.reset(new boost::thread(bind(&worker_thread::run, worker)));
-		  }
-	  }
-
-  };
-
-
-} } } // namespace boost::threadpool::detail
-
-#endif // THREADPOOL_DETAIL_WORKER_THREAD_HPP_INCLUDED
-

+ 0 - 144
Cpp/ThirdParty/boost/threadpool/future.hpp

@@ -1,144 +0,0 @@
-/*! \file
-* \brief TODO.
-*
-* TODO. 
-*
-* Copyright (c) 2005-2007 Philipp Henkel
-*
-* Use, modification, and distribution are  subject to the
-* Boost Software License, Version 1.0. (See accompanying  file
-* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-* http://threadpool.sourceforge.net
-*
-*/
-
-#ifndef THREADPOOL_FUTURE_HPP_INCLUDED
-#define THREADPOOL_FUTURE_HPP_INCLUDED
-
-
-  
-#include "./detail/future.hpp"
-#include <boost/utility/enable_if.hpp>
-
-//#include "pool.hpp"
-//#include <boost/utility.hpp>
-
-//#include <boost/thread/mutex.hpp>
-
-
-namespace boost { namespace threadpool
-{
-
-  /*! \brief Experimental. Do not use in production code. TODO. 
-  *
-  * TODO Future
-  *
-  * \see TODO
-  *
-  */ 
-
-
-template<class Result> 
-class future
-{
-private:
-  shared_ptr<detail::future_impl<Result> > m_impl;
-
-public:
-    typedef Result const & result_type; //!< Indicates the functor's result type.
-    typedef Result future_result_type; //!< Indicates the future's result type.
-
-
-public:
-
-  future()
-  : m_impl(new detail::future_impl<future_result_type>()) // TODO remove this
-  {
-  }
-
-  // only for internal usage
-  future(shared_ptr<detail::future_impl<Result> > const & impl)
-  : m_impl(impl)
-  {
-  }
-
-  bool ready() const
-  {
-    return m_impl->ready();
-  }
-
-  void wait() const
-  {
-    m_impl->wait();
-  }
-
-  bool timed_wait(boost::xtime const & timestamp) const
-  {
-    return m_impl->timed_wait(timestamp);
-  }
-
-   result_type operator()() // throw( thread::cancelation_exception, ... )
-   {
-     return (*m_impl)();
-   }
-
-   result_type get() // throw( thread::cancelation_exception, ... )
-   {
-     return (*m_impl)();
-   }
-
-   bool cancel()
-   {
-     return m_impl->cancel();
-   }
-
-   bool is_cancelled() const
-   {
-     return m_impl->is_cancelled();
-   }
-};
-
-
-
-
-
-template<class Pool, class Function>
-typename disable_if < 
-  is_void< typename result_of< Function() >::type >,
-  future< typename result_of< Function() >::type >
->::type
-schedule(Pool& pool, const Function& task)
-{
-  typedef typename result_of< Function() >::type future_result_type;
-
-  // create future impl and future
-  shared_ptr<detail::future_impl<future_result_type> > impl(new detail::future_impl<future_result_type>);
-  future <future_result_type> res(impl);
-
-  // schedule future impl
-  pool.schedule(detail::future_impl_task_func<detail::future_impl, Function>(task, impl));
-
-  // return future
-  return res;
-
-/*
- TODO
-  if(pool->schedule(bind(&Future::run, future)))
-  {
-    return future;
-  }
-  else
-  {
-    // construct empty future
-    return error_future;
-  }
-  */
-}
-
-
-
-} } // namespace boost::threadpool
-
-#endif // THREADPOOL_FUTURE_HPP_INCLUDED
-

+ 0 - 232
Cpp/ThirdParty/boost/threadpool/pool.hpp

@@ -1,232 +0,0 @@
-/*! \file
-* \brief Thread pool core.
-*
-* This file contains the threadpool's core class: pool<Task, SchedulingPolicy>.
-*
-* Thread pools are a mechanism for asynchronous and parallel processing 
-* within the same process. The pool class provides a convenient way 
-* for dispatching asynchronous tasks as functions objects. The scheduling
-* of these tasks can be easily controlled by using customized schedulers. 
-*
-* Copyright (c) 2005-2007 Philipp Henkel
-*
-* Use, modification, and distribution are  subject to the
-* Boost Software License, Version 1.0. (See accompanying  file
-* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-* http://threadpool.sourceforge.net
-*
-*/
-
-
-#ifndef THREADPOOL_POOL_HPP_INCLUDED
-#define THREADPOOL_POOL_HPP_INCLUDED
-
-#include <boost/ref.hpp>
-
-#include "./detail/pool_core.hpp"
-
-#include "task_adaptors.hpp"
-
-#include "./detail/locking_ptr.hpp"
-
-#include "scheduling_policies.hpp"
-#include "size_policies.hpp"
-#include "shutdown_policies.hpp"
-
-
-
-/// The namespace threadpool contains a thread pool and related utility classes.
-namespace boost { namespace threadpool
-{
-
-
-
-  /*! \brief Thread pool. 
-  *
-  * Thread pools are a mechanism for asynchronous and parallel processing 
-  * within the same process. The pool class provides a convenient way 
-  * for dispatching asynchronous tasks as functions objects. The scheduling
-  * of these tasks can be easily controlled by using customized schedulers. 
-  * A task must not throw an exception.
-  *
-  * A pool is DefaultConstructible, CopyConstructible and Assignable.
-  * It has reference semantics; all copies of the same pool are equivalent and interchangeable. 
-  * All operations on a pool except assignment are strongly thread safe or sequentially consistent; 
-  * that is, the behavior of concurrent calls is as if the calls have been issued sequentially in an unspecified order.
-  *
-  * \param Task A function object which implements the operator 'void operator() (void) const'. The operator () is called by the pool to execute the task. Exceptions are ignored.
-  * \param SchedulingPolicy A task container which determines how tasks are scheduled. It is guaranteed that this container is accessed only by one thread at a time. The scheduler shall not throw exceptions.
-  *
-  * \remarks The pool class is thread-safe.
-  * 
-  * \see Tasks: task_func, prio_task_func
-  * \see Scheduling policies: fifo_scheduler, lifo_scheduler, prio_scheduler
-  */ 
-  template <
-    typename Task                                   = task_func,
-    template <typename> class SchedulingPolicy      = fifo_scheduler,
-    template <typename> class SizePolicy            = static_size,
-    template <typename> class SizePolicyController  = resize_controller,
-    template <typename> class ShutdownPolicy        = wait_for_all_tasks
-  > 
-  class thread_pool 
-  {
-    typedef detail::pool_core<Task, 
-                              SchedulingPolicy,
-                              SizePolicy,
-                              SizePolicyController,
-                              ShutdownPolicy> pool_core_type;
-    shared_ptr<pool_core_type>          m_core; // pimpl idiom
-    shared_ptr<void>                    m_shutdown_controller; // If the last pool holding a pointer to the core is deleted the controller shuts the pool down.
-
-  public: // Type definitions
-    typedef Task task_type;                                   //!< Indicates the task's type.
-    typedef SchedulingPolicy<task_type> scheduler_type;       //!< Indicates the scheduler's type.
- /*   typedef thread_pool<Task, 
-                        SchedulingPolicy,
-                        SizePolicy,
-                        ShutdownPolicy > pool_type;          //!< Indicates the thread pool's type.
- */
-    typedef SizePolicy<pool_core_type> size_policy_type; 
-    typedef SizePolicyController<pool_core_type> size_controller_type;
-
-
-  public:
-    /*! Constructor.
-     * \param initial_threads The pool is immediately resized to set the specified number of threads. The pool's actual number threads depends on the SizePolicy.
-     */
-    thread_pool(size_t initial_threads = 0)
-    : m_core(new pool_core_type)
-    , m_shutdown_controller(static_cast<void*>(0), bind(&pool_core_type::shutdown, m_core))
-    {
-      size_policy_type::init(*m_core, initial_threads);
-    }
-
-
-    /*! Gets the size controller which manages the number of threads in the pool. 
-    * \return The size controller.
-    * \see SizePolicy
-    */
-    size_controller_type size_controller()
-    {
-      return m_core->size_controller();
-    }
-
-
-    /*! Gets the number of threads in the pool.
-    * \return The number of threads.
-    */
-    size_t size()	const
-    {
-      return m_core->size();
-    }
-
-
-     /*! Schedules a task for asynchronous execution. The task will be executed once only.
-     * \param task The task function object. It should not throw execeptions.
-     * \return true, if the task could be scheduled and false otherwise. 
-     */  
-     bool schedule(task_type const & task)
-     {	
-       return m_core->schedule(task);
-     }
-
-
-    /*! Returns the number of tasks which are currently executed.
-    * \return The number of active tasks. 
-    */  
-    size_t active() const
-    {
-      return m_core->active();
-    }
-
-
-    /*! Returns the number of tasks which are ready for execution.    
-    * \return The number of pending tasks. 
-    */  
-    size_t pending() const
-    {
-      return m_core->pending();
-    }
-
-
-    /*! Removes all pending tasks from the pool's scheduler.
-    */  
-    void clear()
-    { 
-      m_core->clear();
-    }    
-
-
-    /*! Indicates that there are no tasks pending. 
-    * \return true if there are no tasks ready for execution.	
-    * \remarks This function is more efficient that the check 'pending() == 0'.
-    */   
-    bool empty() const
-    {
-      return m_core->empty();
-    }	
-
-
-    /*! The current thread of execution is blocked until the sum of all active
-    *  and pending tasks is equal or less than a given threshold. 
-    * \param task_threshold The maximum number of tasks in pool and scheduler.
-    */     
-    void wait(size_t task_threshold = 0) const
-    {
-      m_core->wait(task_threshold);
-    }	
-
-
-    /*! The current thread of execution is blocked until the timestamp is met
-    * or the sum of all active and pending tasks is equal or less 
-    * than a given threshold.  
-    * \param timestamp The time when function returns at the latest.
-    * \param task_threshold The maximum number of tasks in pool and scheduler.
-    * \return true if the task sum is equal or less than the threshold, false otherwise.
-    */       
-    bool wait(xtime const & timestamp, size_t task_threshold = 0) const
-    {
-      return m_core->wait(timestamp, task_threshold);
-    }
-  };
-
-
-
-  /*! \brief Fifo pool.
-  *
-  * The pool's tasks are fifo scheduled task_func functors.
-  *
-  */ 
-  typedef thread_pool<task_func, fifo_scheduler, static_size, resize_controller, wait_for_all_tasks> fifo_pool;
-
-
-  /*! \brief Lifo pool.
-  *
-  * The pool's tasks are lifo scheduled task_func functors.
-  *
-  */ 
-  typedef thread_pool<task_func, lifo_scheduler, static_size, resize_controller, wait_for_all_tasks> lifo_pool;
-
-
-  /*! \brief Pool for prioritized task.
-  *
-  * The pool's tasks are prioritized prio_task_func functors.
-  *
-  */ 
-  typedef thread_pool<prio_task_func, prio_scheduler, static_size, resize_controller, wait_for_all_tasks> prio_pool;
-
-
-  /*! \brief A standard pool.
-  *
-  * The pool's tasks are fifo scheduled task_func functors.
-  *
-  */ 
-  typedef fifo_pool pool;
-
-
-
-} } // namespace boost::threadpool
-
-#endif // THREADPOOL_POOL_HPP_INCLUDED

+ 0 - 70
Cpp/ThirdParty/boost/threadpool/pool_adaptors.hpp

@@ -1,70 +0,0 @@
-/*! \file
-* \brief Pool adaptors.
-*
-* This file contains an easy-to-use adaptor similar to a smart 
-* pointer for the pool class. 
-*
-* Copyright (c) 2005-2007 Philipp Henkel
-*
-* Use, modification, and distribution are  subject to the
-* Boost Software License, Version 1.0. (See accompanying  file
-* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-* http://threadpool.sourceforge.net
-*
-*/
-
-
-#ifndef THREADPOOL_POOL_ADAPTORS_HPP_INCLUDED
-#define THREADPOOL_POOL_ADAPTORS_HPP_INCLUDED
-
-#include <boost/smart_ptr.hpp>
-
-
-namespace boost { namespace threadpool
-{
-
-
-// TODO convenience scheduling function
-    /*! Schedules a Runnable for asynchronous execution. A Runnable is an arbitrary class with a run()
-    * member function. This a convenience shorthand for pool->schedule(bind(&Runnable::run, task_object)).
-    * \param 
-    * \param obj The Runnable object. The member function run() will be exectued and should not throw execeptions.
-    * \return true, if the task could be scheduled and false otherwise. 
-    */  
-    template<typename Pool, typename Runnable>
-    bool schedule(Pool& pool, shared_ptr<Runnable> const & obj)
-    {	
-      return pool->schedule(bind(&Runnable::run, obj));
-    }	
-    
-    /*! Schedules a task for asynchronous execution. The task will be executed once only.
-    * \param task The task function object.
-    */  
-    template<typename Pool>
-    typename enable_if < 
-      is_void< typename result_of< typename Pool::task_type() >::type >,
-      bool
-    >::type
-    schedule(Pool& pool, typename Pool::task_type const & task)
-    {	
-      return pool.schedule(task);
-    }	
-
-
-    template<typename Pool>
-    typename enable_if < 
-      is_void< typename result_of< typename Pool::task_type() >::type >,
-      bool
-    >::type
-    schedule(shared_ptr<Pool> const pool, typename Pool::task_type const & task)
-    {	
-      return pool->schedule(task);
-    }	
-
-
-} } // namespace boost::threadpool
-
-#endif // THREADPOOL_POOL_ADAPTORS_HPP_INCLUDED
-
-

+ 0 - 262
Cpp/ThirdParty/boost/threadpool/scheduling_policies.hpp

@@ -1,262 +0,0 @@
-/*! \file
-* \brief Task scheduling policies.
-*
-* This file contains some fundamental scheduling policies for the pool class. 
-* A scheduling policy is realized by a task container which controls the access to
-* the tasks. 	Fundamentally the container determines the order the tasks are processed
-* by the thread pool. 
-* The task containers need not to be thread-safe because they are used by the pool 
-* in thread-safe way. 
-*
-* Copyright (c) 2005-2007 Philipp Henkel
-*
-* Use, modification, and distribution are  subject to the
-* Boost Software License, Version 1.0. (See accompanying  file
-* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-* http://threadpool.sourceforge.net
-*
-*/
-
-
-#ifndef THREADPOOL_SCHEDULING_POLICIES_HPP_INCLUDED
-#define THREADPOOL_SCHEDULING_POLICIES_HPP_INCLUDED
-
-
-#include <queue>
-#include <deque>
-
-#include "task_adaptors.hpp"
-
-namespace boost { namespace threadpool
-{
-
-  /*! \brief SchedulingPolicy which implements FIFO ordering. 
-  *
-  * This container implements a FIFO scheduling policy.
-  * The first task to be added to the scheduler will be the first to be removed.
-  * The processing proceeds sequentially in the same order. 
-  * FIFO stands for "first in, first out".
-  *
-  * \param Task A function object which implements the operator()(void).
-  *
-  */ 
-  template <typename Task = task_func>  
-  class fifo_scheduler
-  {
-  public:
-    typedef Task task_type; //!< Indicates the scheduler's task type.
-
-  protected:
-    std::deque<task_type> m_container;  //!< Internal task container.	
-
-
-  public:
-    /*! Adds a new task to the scheduler.
-    * \param task The task object.
-    * \return true, if the task could be scheduled and false otherwise. 
-    */
-    bool push(task_type const & task)
-    {
-      m_container.push_back(task);
-      return true;
-    }
-
-    /*! Removes the task which should be executed next.
-    */
-    void pop()
-    {
-      m_container.pop_front();
-    }
-
-    /*! Gets the task which should be executed next.
-    *  \return The task object to be executed.
-    */
-    task_type const & top() const
-    {
-      return m_container.front();
-    }
-
-    /*! Gets the current number of tasks in the scheduler.
-    *  \return The number of tasks.
-    *  \remarks Prefer empty() to size() == 0 to check if the scheduler is empty.
-    */
-    size_t size() const
-    {
-      return m_container.size();
-    }
-
-    /*! Checks if the scheduler is empty.
-    *  \return true if the scheduler contains no tasks, false otherwise.
-    *  \remarks Is more efficient than size() == 0. 
-    */
-    bool empty() const
-    {
-      return m_container.empty();
-    }
-
-    /*! Removes all tasks from the scheduler.
-    */  
-    void clear()
-    {   
-      m_container.clear();
-    } 
-  };
-
-
-
-  /*! \brief SchedulingPolicy which implements LIFO ordering. 
-  *
-  * This container implements a LIFO scheduling policy.
-  * The last task to be added to the scheduler will be the first to be removed.
-  * LIFO stands for "last in, first out".
-  *
-  * \param Task A function object which implements the operator()(void).
-  *
-  */ 
-  template <typename Task = task_func>  
-  class lifo_scheduler
-  {
-  public:
-    typedef Task task_type;  //!< Indicates the scheduler's task type.
-
-  protected:
-    std::deque<task_type> m_container;  //!< Internal task container.	
-
-  public:
-    /*! Adds a new task to the scheduler.
-    * \param task The task object.
-    * \return true, if the task could be scheduled and false otherwise. 
-    */
-    bool push(task_type const & task)
-    {
-      m_container.push_front(task);
-      return true;
-    }
-
-    /*! Removes the task which should be executed next.
-    */
-    void pop()
-    {
-      m_container.pop_front();
-    }
-
-    /*! Gets the task which should be executed next.
-    *  \return The task object to be executed.
-    */
-    task_type const & top() const
-    {
-      return m_container.front();
-    }
-
-    /*! Gets the current number of tasks in the scheduler.
-    *  \return The number of tasks.
-    *  \remarks Prefer empty() to size() == 0 to check if the scheduler is empty.
-    */
-    size_t size() const
-    {
-      return m_container.size();
-    }
-
-    /*! Checks if the scheduler is empty.
-    *  \return true if the scheduler contains no tasks, false otherwise.
-    *  \remarks Is more efficient than size() == 0. 
-    */
-    bool empty() const
-    {
-      return m_container.empty();
-    }
-
-    /*! Removes all tasks from the scheduler.
-    */  
-    void clear()
-    {    
-      m_container.clear();
-    } 
-
-  };
-
-
-
-  /*! \brief SchedulingPolicy which implements prioritized ordering. 
-  *
-  * This container implements a scheduling policy based on task priorities.
-  * The task with highest priority will be the first to be removed.
-  * It must be possible to compare two tasks using operator<. 
-  *
-  * \param Task A function object which implements the operator() and operator<. operator< must be a partial ordering.
-  *
-  * \see prio_thread_func
-  *
-  */ 
-  template <typename Task = prio_task_func>  
-  class prio_scheduler
-  {
-  public:
-    typedef Task task_type; //!< Indicates the scheduler's task type.
-
-  protected:
-    std::priority_queue<task_type> m_container;  //!< Internal task container.
-
-
-  public:
-    /*! Adds a new task to the scheduler.
-    * \param task The task object.
-    * \return true, if the task could be scheduled and false otherwise. 
-    */
-    bool push(task_type const & task)
-    {
-      m_container.push(task);
-      return true;
-    }
-
-    /*! Removes the task which should be executed next.
-    */
-    void pop()
-    {
-      m_container.pop();
-    }
-
-    /*! Gets the task which should be executed next.
-    *  \return The task object to be executed.
-    */
-    task_type const & top() const
-    {
-      return m_container.top();
-    }
-
-    /*! Gets the current number of tasks in the scheduler.
-    *  \return The number of tasks.
-    *  \remarks Prefer empty() to size() == 0 to check if the scheduler is empty.
-    */
-    size_t size() const
-    {
-      return m_container.size();
-    }
-
-    /*! Checks if the scheduler is empty.
-    *  \return true if the scheduler contains no tasks, false otherwise.
-    *  \remarks Is more efficient than size() == 0. 
-    */
-    bool empty() const
-    {
-      return m_container.empty();
-    }
-
-    /*! Removes all tasks from the scheduler.
-    */  
-    void clear()
-    {    
-      while(!m_container.empty())
-      {
-        m_container.pop();
-      }
-    } 
-  };
-
-
-} } // namespace boost::threadpool
-
-
-#endif // THREADPOOL_SCHEDULING_POLICIES_HPP_INCLUDED
-

+ 0 - 83
Cpp/ThirdParty/boost/threadpool/shutdown_policies.hpp

@@ -1,83 +0,0 @@
-/*! \file
-* \brief Shutdown policies.
-*
-* This file contains shutdown policies for thread_pool. 
-* A shutdown policy controls the pool's behavior from the time
-* when the pool is not referenced any longer.
-*
-* Copyright (c) 2005-2007 Philipp Henkel
-*
-* Use, modification, and distribution are  subject to the
-* Boost Software License, Version 1.0. (See accompanying  file
-* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-* http://threadpool.sourceforge.net
-*
-*/
-
-
-#ifndef THREADPOOL_SHUTDOWN_POLICIES_HPP_INCLUDED
-#define THREADPOOL_SHUTDOWN_POLICIES_HPP_INCLUDED
-
-
-
-/// The namespace threadpool contains a thread pool and related utility classes.
-namespace boost { namespace threadpool
-{
-
-
-/*! \brief ShutdownPolicy which waits for the completion of all tasks 
-  *          and the worker termination afterwards.
-    *
-  * \param Pool The pool's core type.
-  */ 
-  template<typename Pool>
-  class wait_for_all_tasks
-  {
-  public:
-    static void shutdown(Pool& pool)
-    {
-      pool.wait();
-      pool.terminate_all_workers(true);
-    }
-  };
-
-
-  /*! \brief ShutdownPolicy which waits for the completion of all active tasks 
-  *          and the worker termination afterwards.
-  *
-  * \param Pool The pool's core type.
-  */ 
-  template<typename Pool>
-  class wait_for_active_tasks
-  {
-  public:
-    static void shutdown(Pool& pool)
-    {
-      pool.clear();
-      pool.wait();
-      pool.terminate_all_workers(true);
-    }
-  };
-
-
-  /*! \brief ShutdownPolicy which does not wait for any tasks or worker termination.
-  *
-  * This policy does not wait for any tasks. Nevertheless all active tasks will be processed completely.
-  *
-  * \param Pool The pool's core type.
-  */ 
-  template<typename Pool>
-  class immediately
-  {
-  public:
-    static void shutdown(Pool& pool)
-    {
-      pool.clear();
-      pool.terminate_all_workers(false);
-    }
-  };
-
-} } // namespace boost::threadpool
-
-#endif // THREADPOOL_SHUTDOWN_POLICIES_HPP_INCLUDED

+ 0 - 99
Cpp/ThirdParty/boost/threadpool/size_policies.hpp

@@ -1,99 +0,0 @@
-/*! \file
-* \brief Size policies.
-*
-* This file contains size policies for thread_pool. A size 
-* policy controls the number of worker threads in the pool.
-*
-* Copyright (c) 2005-2007 Philipp Henkel
-*
-* Use, modification, and distribution are  subject to the
-* Boost Software License, Version 1.0. (See accompanying  file
-* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-* http://threadpool.sourceforge.net
-*
-*/
-
-
-#ifndef THREADPOOL_SIZE_POLICIES_HPP_INCLUDED
-#define THREADPOOL_SIZE_POLICIES_HPP_INCLUDED
-
-
-
-/// The namespace threadpool contains a thread pool and related utility classes.
-namespace boost { namespace threadpool
-{
-
-  /*! \brief SizePolicyController which provides no boost/bind.hppity.
-  *
-  * \param Pool The pool's core type.
-  */ 
-  template<typename Pool>
-  struct empty_controller
-  {
-    empty_controller(typename Pool::size_policy_type&, shared_ptr<Pool>) {}
-  };
-
-
-  /*! \brief SizePolicyController which allows resizing.
-  *
-  * \param Pool The pool's core type.
-  */ 
-  template< typename Pool >
-  class resize_controller
-  {
-    typedef typename Pool::size_policy_type size_policy_type;
-    reference_wrapper<size_policy_type> m_policy;
-    shared_ptr<Pool> m_pool;                           //!< to make sure that the pool is alive (the policy pointer is valid) as long as the controller exists
-
-  public:
-    resize_controller(size_policy_type& policy, shared_ptr<Pool> pool)
-      : m_policy(policy)
-      , m_pool(pool)
-    {
-    }
-
-    bool resize(size_t worker_count)
-    {
-      return m_policy.get().resize(worker_count);
-    }
-  };
-
-
-  /*! \brief SizePolicy which preserves the thread count.
-  *
-  * \param Pool The pool's core type.
-  */ 
-  template<typename Pool>
-  class static_size
-  {
-    reference_wrapper<Pool volatile> m_pool;
-
-  public:
-    static void init(Pool& pool, size_t const worker_count)
-    {
-      pool.resize(worker_count);
-    }
-
-    static_size(Pool volatile & pool)
-      : m_pool(pool)
-    {}
-
-    bool resize(size_t const worker_count)
-    {
-      return m_pool.get().resize(worker_count);
-    }
-
-    void worker_died_unexpectedly(size_t const new_worker_count)
-    {
-      m_pool.get().resize(new_worker_count + 1);
-    }
-
-    // TODO this functions are not called yet
-    void task_scheduled() {}
-    void task_finished() {}
-  };
-
-} } // namespace boost::threadpool
-
-#endif // THREADPOOL_SIZE_POLICIES_HPP_INCLUDED

+ 0 - 168
Cpp/ThirdParty/boost/threadpool/task_adaptors.hpp

@@ -1,168 +0,0 @@
-/*! \file
-* \brief Task adaptors.
-*
-* This file contains adaptors for task function objects.
-*
-* Copyright (c) 2005-2007 Philipp Henkel
-*
-* Use, modification, and distribution are  subject to the
-* Boost Software License, Version 1.0. (See accompanying  file
-* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-*
-* http://threadpool.sourceforge.net
-*
-*/
-
-
-#ifndef THREADPOOL_TASK_ADAPTERS_HPP_INCLUDED
-#define THREADPOOL_TASK_ADAPTERS_HPP_INCLUDED
-
-
-#include <boost/smart_ptr.hpp>
-#include <boost/function.hpp>
-#include <boost/thread.hpp>
-
-
-namespace boost { namespace threadpool
-{
-
-  /*! \brief Standard task function object.
-  *
-  * This function object wraps a nullary function which returns void.
-  * The wrapped function is invoked by calling the operator ().
-  *
-  * \see boost function library
-  *
-  */ 
-  typedef function0<void> task_func;
-
-
-
-
-  /*! \brief Prioritized task function object. 
-  *
-  * This function object wraps a task_func object and binds a priority to it.
-  * prio_task_funcs can be compared using the operator < which realises a partial ordering.
-  * The wrapped task function is invoked by calling the operator ().
-  *
-  * \see prio_scheduler
-  *
-  */ 
-  class prio_task_func
-  {
-  private:
-    unsigned int m_priority;  //!< The priority of the task's function.
-    task_func m_function;     //!< The task's function.
-
-  public:
-    typedef void result_type; //!< Indicates the functor's result type.
-
-  public:
-    /*! Constructor.
-    * \param priority The priority of the task.
-    * \param function The task's function object.
-    */
-    prio_task_func(unsigned int const priority, task_func const & function)
-      : m_priority(priority)
-      , m_function(function)
-    {
-    }
-
-    /*! Executes the task function.
-    */
-    void operator() (void) const
-    {
-      if(m_function)
-      {
-        m_function();
-      }
-    }
-
-    /*! Comparison operator which realises a partial ordering based on priorities.
-    * \param rhs The object to compare with.
-    * \return true if the priority of *this is less than right hand side's priority, false otherwise.
-    */
-    bool operator< (const prio_task_func& rhs) const
-    {
-      return m_priority < rhs.m_priority; 
-    }
-
-  };  // prio_task_func
-
-
-
- 
-
-
-
-
-  /*! \brief Looped task function object. 
-  *
-  * This function object wraps a boolean thread function object.
-  * The wrapped task function is invoked by calling the operator () and it is executed in regular 
-  * time intervals until false is returned. The interval length may be zero.
-  * Please note that a pool's thread is engaged as long as the task is looped.
-  *
-  */ 
-  class looped_task_func
-  {
-  private:
-    function0<bool> m_function;   //!< The task's function.
-    unsigned int m_break_s;              //!< Duration of breaks in seconds.
-    unsigned int m_break_ns;             //!< Duration of breaks in nano seconds.
-
-  public:
-    typedef void result_type; //!< Indicates the functor's result type.
-
-  public:
-    /*! Constructor.
-    * \param function The task's function object which is looped until false is returned.
-    * \param interval The minimum break time in milli seconds before the first execution of the task function and between the following ones.
-    */
-    looped_task_func(function0<bool> const & function, unsigned int const interval = 0)
-      : m_function(function)
-    {
-      m_break_s  = interval / 1000;
-      m_break_ns = (interval - m_break_s * 1000) * 1000 * 1000;
-    }
-
-    /*! Executes the task function.
-    */
-    void operator() (void) const
-    {
-      if(m_function)
-      {
-        if(m_break_s > 0 || m_break_ns > 0)
-        { // Sleep some time before first execution
-          xtime xt;
-          xtime_get(&xt, TIME_UTC);
-          xt.nsec += m_break_ns;
-          xt.sec += m_break_s;
-          thread::sleep(xt); 
-        }
-
-        while(m_function())
-        {
-          if(m_break_s > 0 || m_break_ns > 0)
-          {
-            xtime xt;
-            xtime_get(&xt, TIME_UTC);
-            xt.nsec += m_break_ns;
-            xt.sec += m_break_s;
-            thread::sleep(xt); 
-          }
-          else
-          {
-            thread::yield(); // Be fair to other threads
-          }
-        }
-      }
-    }
-
-  }; // looped_task_func
-
-
-} } // namespace boost::threadpool
-
-#endif // THREADPOOL_TASK_ADAPTERS_HPP_INCLUDED
-