| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -156,16 +156,17 @@ bool ThreadPool::busy(){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					IntervalBasedTriggerHost::IntervalBasedTriggerHost(ThreadPool* tp){
 | 
					 | 
					 | 
					 | 
					IntervalBasedTriggerHost::IntervalBasedTriggerHost(ThreadPool* tp){
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    this->tp = tp;
 | 
					 | 
					 | 
					 | 
					    this->tp = tp;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    this->triggers = new vector_type<IntervalBasedTrigger>;
 | 
					 | 
					 | 
					 | 
					    this->triggers = new aq_map<std::string, IntervalBasedTrigger>;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    trigger_queue_lock = new mutex();
 | 
					 | 
					 | 
					 | 
					    trigger_queue_lock = new mutex();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    this->now = std::chrono::high_resolution_clock::now().time_since_epoch().count();
 | 
					 | 
					 | 
					 | 
					    this->now = std::chrono::high_resolution_clock::now().time_since_epoch().count();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					void IntervalBasedTriggerHost::add_trigger(StoredProcedure *p, uint32_t interval) {
 | 
					 | 
					 | 
					 | 
					void IntervalBasedTriggerHost::add_trigger(const char* name, StoredProcedure *p, uint32_t interval) {
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    auto tr = IntervalBasedTrigger{.interval = interval, .time_remaining = 0, .sp = p};
 | 
					 | 
					 | 
					 | 
					    auto tr = IntervalBasedTrigger{.interval = interval, .time_remaining = 0, .sp = p};
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    auto vt_triggers = static_cast<vector_type<IntervalBasedTrigger> *>(this->triggers);
 | 
					 | 
					 | 
					 | 
					    auto vt_triggers = static_cast<aq_map<std::string, IntervalBasedTrigger> *>(this->triggers);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    trigger_queue_lock->lock();
 | 
					 | 
					 | 
					 | 
					    trigger_queue_lock->lock();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    vt_triggers->emplace_back(tr);
 | 
					 | 
					 | 
					 | 
					    vt_triggers->emplace(name, tr);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    //(*vt_triggers)[name] = tr;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    trigger_queue_lock->unlock();
 | 
					 | 
					 | 
					 | 
					    trigger_queue_lock->unlock();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -173,9 +174,9 @@ void IntervalBasedTriggerHost::tick() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const auto current_time = std::chrono::high_resolution_clock::now().time_since_epoch().count();
 | 
					 | 
					 | 
					 | 
					    const auto current_time = std::chrono::high_resolution_clock::now().time_since_epoch().count();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const auto delta_t = static_cast<uint32_t>((current_time - now) / 1000000); // miliseconds precision
 | 
					 | 
					 | 
					 | 
					    const auto delta_t = static_cast<uint32_t>((current_time - now) / 1000000); // miliseconds precision
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    now = current_time;
 | 
					 | 
					 | 
					 | 
					    now = current_time;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    auto vt_triggers = static_cast<vector_type<IntervalBasedTrigger> *>(this->triggers);
 | 
					 | 
					 | 
					 | 
					    auto vt_triggers = static_cast<aq_map<std::string, IntervalBasedTrigger> *>(this->triggers);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    trigger_queue_lock->lock();
 | 
					 | 
					 | 
					 | 
					    trigger_queue_lock->lock();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    for(auto& t : *vt_triggers) {
 | 
					 | 
					 | 
					 | 
					    for(auto& [_, t] : vt_triggers->values()) {
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if(t.tick(delta_t)) {
 | 
					 | 
					 | 
					 | 
					        if(t.tick(delta_t)) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            payload_t payload;
 | 
					 | 
					 | 
					 | 
					            payload_t payload;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            payload.f = execTriggerPayload;
 | 
					 | 
					 | 
					 | 
					            payload.f = execTriggerPayload;
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -187,6 +188,11 @@ void IntervalBasedTriggerHost::tick() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    trigger_queue_lock->unlock();
 | 
					 | 
					 | 
					 | 
					    trigger_queue_lock->unlock();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					void IntervalBasedTriggerHost::remove_trigger(const char* name) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    auto vt_triggers = static_cast<aq_map<std::string, IntervalBasedTrigger> *>(this->triggers);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    vt_triggers->erase(name);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					void IntervalBasedTrigger::reset() {
 | 
					 | 
					 | 
					 | 
					void IntervalBasedTrigger::reset() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    time_remaining = interval;
 | 
					 | 
					 | 
					 | 
					    time_remaining = interval;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -201,3 +207,9 @@ bool IntervalBasedTrigger::tick(uint32_t delta_t) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        time_remaining = time_remaining - curr_dt;
 | 
					 | 
					 | 
					 | 
					        time_remaining = time_remaining - curr_dt;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return ret;
 | 
					 | 
					 | 
					 | 
					    return ret;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					CallbackBasedTriggerHost::CallbackBasedTriggerHost(ThreadPool *tp) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    this->tp = tp;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					void CallbackBasedTriggerHost::tick() {}
 |