diff options
| author | randomdan <randomdan@localhost> | 2014-03-12 16:28:25 +0000 | 
|---|---|---|
| committer | randomdan <randomdan@localhost> | 2014-03-12 16:28:25 +0000 | 
| commit | 45f53c5e5bc3fe007acda1860b8cf41e6b224bfe (patch) | |
| tree | 27af8acacab2d6ab3e9676500b6aa0fa69b8b73a | |
| parent | Don't require the Ice comms code to be compiled if an existing library can su... (diff) | |
| download | project2-45f53c5e5bc3fe007acda1860b8cf41e6b224bfe.tar.bz2 project2-45f53c5e5bc3fe007acda1860b8cf41e6b224bfe.tar.xz project2-45f53c5e5bc3fe007acda1860b8cf41e6b224bfe.zip  | |
Build ICE modules in parallel
| -rw-r--r-- | project2/ice/iceCompile.cpp | 4 | ||||
| -rw-r--r-- | project2/ice/iceCompile.h | 5 | ||||
| -rw-r--r-- | project2/ice/iceDaemon.cpp | 10 | ||||
| -rw-r--r-- | project2/ice/iceDataSource.cpp | 59 | ||||
| -rw-r--r-- | project2/ice/iceDataSource.h | 10 | 
5 files changed, 68 insertions, 20 deletions
diff --git a/project2/ice/iceCompile.cpp b/project2/ice/iceCompile.cpp index 1be126c..3df8dbd 100644 --- a/project2/ice/iceCompile.cpp +++ b/project2/ice/iceCompile.cpp @@ -43,6 +43,10 @@ IceCompile::IceCompile(const boost::filesystem::path & s, const Deps & d) :  {  } +IceCompile::~IceCompile() +{ +} +  void  IceCompile::Update(int steps) const  { diff --git a/project2/ice/iceCompile.h b/project2/ice/iceCompile.h index 762b419..d849ac6 100644 --- a/project2/ice/iceCompile.h +++ b/project2/ice/iceCompile.h @@ -10,7 +10,9 @@ class IceCompile {  	public:  		INITOPTIONS; -		typedef std::vector<const IceCompile *> Deps; +		typedef boost::shared_ptr<IceCompile> Ptr; +		typedef boost::shared_ptr<const IceCompile> CPtr; +		typedef std::vector<CPtr> Deps;  		static std::string slice2cpp;  		static std::string cxx; @@ -22,6 +24,7 @@ class IceCompile {  		IceCompile(const boost::filesystem::path & slice);  		IceCompile(const boost::filesystem::path & slice, const Deps & deps); +		virtual ~IceCompile();  		enum Steps {  			UpdateBuild = 0x1, diff --git a/project2/ice/iceDaemon.cpp b/project2/ice/iceDaemon.cpp index 01acb36..7dcf298 100644 --- a/project2/ice/iceDaemon.cpp +++ b/project2/ice/iceDaemon.cpp @@ -62,12 +62,12 @@ IceDaemon::run() const  {  	Logger()->messagebf(LOG_INFO, ">>> %s compiling slice '%s'...", __PRETTY_FUNCTION__, slice); -	BuildComms bc(slice); -	BuildShared bds(slice, { &bc }); -	BuildDaemon bd(slice, { &bds }); -	bd.Update(); +	IceCompile::CPtr bc(new BuildComms(slice)); +	IceCompile::CPtr bds(new BuildShared(slice, { bc })); +	IceCompile::CPtr bd(new BuildDaemon(slice, { bds })); +	bd->Update(); -	auto library = bd.Open(); +	auto library = bd->Open();  	Logger()->messagebf(LOG_INFO, "  %s starting...", __PRETTY_FUNCTION__);  	Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints(adapterName, adapterEndpoint); diff --git a/project2/ice/iceDataSource.cpp b/project2/ice/iceDataSource.cpp index 7b77b19..064a69f 100644 --- a/project2/ice/iceDataSource.cpp +++ b/project2/ice/iceDataSource.cpp @@ -27,23 +27,51 @@ void  IceDataSource::SetSlice(const VariableType & vslice)  {  	auto slice = vslice.as<std::string>(); -	BuildComms bc(slice); -	BuildShared bcs(slice, { &bc }); -	BuildClient bcl(slice, { &bcs }); -	bcl.Update(); -	libs.insert({ slice, bcl.Open() }); +	IceCompile::CPtr bc(new BuildComms(slice)); +	bc->Update(IceCompile::UpdateBuild); +	IceCompile::CPtr bcs(new BuildShared(slice, { bc })); +	IceCompile::CPtr bcl(new BuildClient(slice, { bcs })); +	libs.push_back(LibCompile(bcl, new std::thread(&IceCompile::Update, bcl.get(), +					IceCompile::UpdateBuild | IceCompile::UpdateCompile | IceCompile::UpdateLink)));  }  void  IceDataSource::SetSliceClient(const VariableType & vslice)  {  	auto slice = vslice.as<std::string>(); -	BuildComms bc(slice); -	bc.Update(IceCompile::UpdateBuild); -	BuildShared bcs(slice, { }); -	BuildClient bcl(slice, { &bcs }); -	bcl.Update(); -	libs.insert({ slice, bcl.Open() }); +	IceCompile::CPtr bc(new BuildComms(slice)); +	bc->Update(IceCompile::UpdateBuild); +	IceCompile::CPtr bcs(new BuildShared(slice, { })); +	IceCompile::CPtr bcl(new BuildClient(slice, { bcs })); +	libs.push_back(LibCompile(bcl, new std::thread(&IceCompile::Update, bcl.get(), +					IceCompile::UpdateBuild | IceCompile::UpdateCompile | IceCompile::UpdateLink))); +} + +class WaitAndLoad : public boost::static_visitor<> { +	public: +		WaitAndLoad(IceDataSource::LibPromise & l) : lib(l) { } + +		void operator()(IceDataSource::LibCompile & th) const +		{ +			boost::get<1>(th)->join(); +			delete boost::get<1>(th); +			lib = boost::get<0>(th)->Open(); +		} + +		void operator()(IceCompile::LibHandle) const +		{ +		} + +	private: +		IceDataSource::LibPromise & lib; +}; + +void +IceDataSource::FinaliseLoad() +{ +	BOOST_FOREACH(auto & lib, libs) { +		boost::apply_visitor(WaitAndLoad(lib), lib); +	}  }  void @@ -53,5 +81,12 @@ IceDataSource::ClearSlice()  	proxies.clear();  } -DECLARE_LOADER("icedatasource", IceDataSource); +class IceDataSourceLoader : public ElementLoader::For<IceDataSource> { +	public: +		void onConfigLoad() override { +			IceDataSource::FinaliseLoad(); +		} +}; + +DECLARE_CUSTOM_LOADER("icedatasource", IceDataSourceLoader); diff --git a/project2/ice/iceDataSource.h b/project2/ice/iceDataSource.h index fe07bc1..b145fe5 100644 --- a/project2/ice/iceDataSource.h +++ b/project2/ice/iceDataSource.h @@ -6,11 +6,16 @@  #include <variables.h>  #include "iceCompile.h"  #include <Ice/Communicator.h> +#include <thread> +#include <boost/tuple/tuple.hpp>  class IceDataSource : public DataSource {    public:      INITOPTIONS; -    static std::string slice; + +		typedef boost::tuple<IceCompile::CPtr, std::thread *> LibCompile; +		typedef boost::variant<LibCompile, IceCompile::LibHandle> LibPromise; +		typedef std::vector<LibPromise> Libs;  		IceDataSource(ScriptNodePtr p); @@ -26,11 +31,12 @@ class IceDataSource : public DataSource {  			return Interface::checkedCast(existingProxy->second);  		} +		static void FinaliseLoad(); +  	private:  		static void SetSlice(const VariableType &);  		static void SetSliceClient(const VariableType &);  		static void ClearSlice(); -		typedef std::map<std::string, IceCompile::LibHandle> Libs;  		static Libs libs;  		const Variable endpoint;  | 
