TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/host/ThreadEnv.cpp
Go to the documentation of this file.
00001 #include "ThreadEnv.hpp"
00002 
00003 #include "Graph.hpp"
00004 #include "ComputeOptions.hpp"
00005 
00006 namespace tuttle {
00007 namespace host {
00008 
00009 void ThreadEnv::runProcessFunc( ThreadEnv* threadEnv, Graph& graph, const std::list<std::string>& nodes )
00010 {
00011         try
00012         {
00013                 threadEnv->setResult( graph.compute( threadEnv->_imageCache, nodes, threadEnv->_options ) );
00014         }
00015         catch(...)
00016         {
00017                 threadEnv->setResult( false );  // error during the process.
00018                 TUTTLE_LOG_ERROR( "[Process render] Error.");
00019                 TUTTLE_LOG_ERROR( boost::current_exception_diagnostic_information() );
00020                 core().getMemoryCache().clearUnused();
00021         }
00022         threadEnv->setIsRunning(false);
00023         threadEnv->getSignalEnd()();
00024 }
00025 
00026 void ThreadEnv::compute( Graph& graph, const NodeListArg& nodes )
00027 {
00028         if( _asynchronous )
00029         {
00030                 setIsRunning(true);
00031                 _thread = boost::thread( runProcessFunc, this, graph, nodes.getNodes() );
00032         }
00033         else
00034         {
00035                 setResult( graph.compute( _imageCache, nodes, _options ) );
00036         }
00037 }
00038 
00039 }
00040 }