SEGS  0.6.1-develop [d2cac982]
Super Entity Game Server
SEGSTimer.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2019 SEGS Team (see AUTHORS.md)
5  * This software is licensed under the terms of the 3-clause BSD License. See LICENSE.md for details.
6  */
7 
8 #pragma once
9 #include <ace/Timer_Queue_Adapters.h>
10 //#include <ace/Timer_Heap.h>
11 #include <ace/Timer_List.h>
12 #include <ace/Timer_Hash.h>
13 //#include <ace/Timer_Wheel.h>
14 #include <ace/Activation_Queue.h>
15 
16 class EventProcessor;
18 class SEGSTimer
19 {
20 protected:
21  long m_id;
22  uint64_t m_user_id;
24  ACE_Time_Value m_fire_delta_time;
25  bool m_one_shot;
26 public:
27  SEGSTimer(EventProcessor *m_processor,uint64_t data,const ACE_Time_Value &fire_delta_time,bool one_shot=true);
28  ~SEGSTimer();
29  void schedule();
30  void cancel();
31  void reset();
32  void reschedule(const ACE_Time_Value &new_time);
33  EventProcessor * target() const {return m_target;}
34  uint64_t user_id() const {return m_user_id;}
35  void schedule_repeatable();
36 };
37 typedef ACE_Thread_Timer_Queue_Adapter<ACE_Timer_List> Thread_Timer_Queue;
38 typedef ACE_Singleton<Thread_Timer_Queue,ACE_Thread_Mutex> GlobalTimerQueue;
Instances of SEGSTimer class are used to schedule events in the future.
Definition: SEGSTimer.h:18
void reset()
Definition: SEGSTimer.cpp:48
void schedule()
Definition: SEGSTimer.cpp:35
~SEGSTimer()
Definition: SEGSTimer.cpp:28
ACE_Time_Value m_fire_delta_time
Definition: SEGSTimer.h:24
ACE_Singleton< Thread_Timer_Queue, ACE_Thread_Mutex > GlobalTimerQueue
Definition: SEGSTimer.h:38
EventProcessor * m_target
Definition: SEGSTimer.h:23
void schedule_repeatable()
Definition: SEGSTimer.cpp:64
uint64_t user_id() const
Definition: SEGSTimer.h:34
SEGSTimer(EventProcessor *m_processor, uint64_t data, const ACE_Time_Value &fire_delta_time, bool one_shot=true)
Definition: SEGSTimer.cpp:17
EventProcessor * target() const
Definition: SEGSTimer.h:33
void reschedule(const ACE_Time_Value &new_time)
Definition: SEGSTimer.cpp:57
long m_id
Definition: SEGSTimer.h:21
void cancel()
Definition: SEGSTimer.cpp:41
ACE_Thread_Timer_Queue_Adapter< ACE_Timer_List > Thread_Timer_Queue
Definition: SEGSTimer.h:37
Definition: EventProcessor.h:22
bool m_one_shot
Definition: SEGSTimer.h:25
uint64_t m_user_id
Definition: SEGSTimer.h:22