Mercurial > hg > orthanc
comparison UnitTestsSources/MultiThreadingTests.cpp @ 2604:76ef12fa136c jobs
fix race conditions if creating Lua jobs
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 18 May 2018 17:37:14 +0200 |
parents | 988936118354 |
children | f2b9d3256060 |
comparison
equal
deleted
inserted
replaced
2603:988936118354 | 2604:76ef12fa136c |
---|---|
786 { | 786 { |
787 JobsEngine engine; | 787 JobsEngine engine; |
788 engine.SetWorkersCount(2); | 788 engine.SetWorkersCount(2); |
789 engine.Start(); | 789 engine.Start(); |
790 | 790 |
791 LuaJobManager lua(engine); | 791 LuaJobManager lua; |
792 lua.SetMaxOperationsPerJob(5); | 792 lua.SetMaxOperationsPerJob(5); |
793 lua.SetTrailingOperationTimeout(200); | 793 lua.SetTrailingOperationTimeout(200); |
794 | 794 |
795 for (size_t i = 0; i < 30; i++) | 795 for (size_t i = 0; i < 30; i++) |
796 { | 796 { |
797 boost::this_thread::sleep(boost::posix_time::milliseconds(150)); | 797 boost::this_thread::sleep(boost::posix_time::milliseconds(150)); |
798 std::auto_ptr<LuaJobManager::Lock> lock(lua.Modify()); | 798 |
799 size_t a = lock->AddOperation(new LogJobOperation); | 799 LuaJobManager::Lock lock(lua, engine); |
800 lock->AddInput(a, StringOperationValue(boost::lexical_cast<std::string>(i))); | 800 size_t a = lock.AddLogOperation(); |
801 size_t b = lock.AddLogOperation(); | |
802 lock.AddStringInput(a, boost::lexical_cast<std::string>(i)); | |
803 lock.AddNullInput(a); | |
804 lock.Connect(a, b); | |
801 } | 805 } |
802 | 806 |
803 boost::this_thread::sleep(boost::posix_time::milliseconds(2000)); | 807 boost::this_thread::sleep(boost::posix_time::milliseconds(2000)); |
804 | 808 |
805 engine.Stop(); | 809 engine.Stop(); |