comparison OrthancServer/Sources/LuaScripting.cpp @ 5023:c8c98389080f

use constant for multiply occurring string
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 17 Jun 2022 07:23:57 +0200
parents 3d0a084e1ace
children 06ffe03d008a
comparison
equal deleted inserted replaced
5022:3d0a084e1ace 5023:c8c98389080f
32 #include "../../OrthancFramework/Sources/Logging.h" 32 #include "../../OrthancFramework/Sources/Logging.h"
33 #include "../../OrthancFramework/Sources/Lua/LuaFunctionCall.h" 33 #include "../../OrthancFramework/Sources/Lua/LuaFunctionCall.h"
34 34
35 #include <OrthancServerResources.h> 35 #include <OrthancServerResources.h>
36 36
37 static const char* ON_HEART_BEAT = "OnHeartBeat";
38
37 39
38 namespace Orthanc 40 namespace Orthanc
39 { 41 {
40 class LuaScripting::IEvent : public IDynamicObject 42 class LuaScripting::IEvent : public IDynamicObject
41 { 43 {
801 803
802 if (boost::posix_time::microsec_clock::universal_time() >= next) 804 if (boost::posix_time::microsec_clock::universal_time() >= next)
803 { 805 {
804 LuaScripting::Lock lock(*that); 806 LuaScripting::Lock lock(*that);
805 807
806 if (lock.GetLua().IsExistingFunction("OnHeartBeat")) 808 if (lock.GetLua().IsExistingFunction(ON_HEART_BEAT))
807 { 809 {
808 LuaFunctionCall call(lock.GetLua(), "OnHeartBeat"); 810 LuaFunctionCall call(lock.GetLua(), ON_HEART_BEAT);
809 call.Execute(); 811 call.Execute();
810 } 812 }
811 813
812 next = boost::posix_time::microsec_clock::universal_time() + PERIODICITY; 814 next = boost::posix_time::microsec_clock::universal_time() + PERIODICITY;
813 } 815 }
866 LOG(INFO) << "Starting the Lua engine"; 868 LOG(INFO) << "Starting the Lua engine";
867 eventThread_ = boost::thread(EventThread, this); 869 eventThread_ = boost::thread(EventThread, this);
868 870
869 LuaScripting::Lock lock(*this); 871 LuaScripting::Lock lock(*this);
870 872
871 if (heartBeatPeriod_ > 0 && lock.GetLua().IsExistingFunction("OnHeartBeat")) 873 if (heartBeatPeriod_ > 0 && lock.GetLua().IsExistingFunction(ON_HEART_BEAT))
872 { 874 {
873 LOG(INFO) << "Starting the Lua HeartBeat thread with a period of " << heartBeatPeriod_ << " seconds"; 875 LOG(INFO) << "Starting the Lua HeartBeat thread with a period of " << heartBeatPeriod_ << " seconds";
874 heartBeatThread_ = boost::thread(HeartBeatThread, this); 876 heartBeatThread_ = boost::thread(HeartBeatThread, this);
875 } 877 }
876 state_ = State_Running; 878 state_ = State_Running;