File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 44
55// VS2013不支持thread_local
66#if defined(_MSC_VER) && _MSC_VER < 1900
7- #define thread_local __declspec (thread)
7+ # define thread_local __declspec (thread)
8+ # define UNSUPPORT_STEADY_TIME
89#endif
910
1011#if __linux__
Original file line number Diff line number Diff line change 11#include " timer.h"
22#include < mutex>
33#include < limits>
4+ #include < algorithm>
45
56namespace co
67{
@@ -65,6 +66,8 @@ CoTimerPtr CoTimerMgr::ExpireAt(SystemTimePoint const& time_point,
6566 sptr->system_token_ = system_deadlines_.insert (std::make_pair (time_point, sptr));
6667 return sptr;
6768}
69+
70+ #ifndef UNSUPPORT_STEADY_TIME
6871CoTimerPtr CoTimerMgr::ExpireAt (SteadyTimePoint const & time_point,
6972 CoTimer::fn_t const & fn)
7073{
@@ -76,6 +79,7 @@ CoTimerPtr CoTimerMgr::ExpireAt(SteadyTimePoint const& time_point,
7679 sptr->steady_token_ = steady_deadlines_.insert (std::make_pair (time_point, sptr));
7780 return sptr;
7881}
82+ #endif
7983
8084bool CoTimerMgr::Cancel (CoTimerPtr co_timer_ptr)
8185{
@@ -188,9 +192,11 @@ void CoTimerMgr::SetNextTriggerTime(SystemTimePoint const& sys_tp)
188192 system_next_trigger_time_ = std::chrono::time_point_cast<std::chrono::milliseconds>(sys_tp).time_since_epoch ().count ();
189193}
190194
195+ #ifndef UNSUPPORT_STEADY_TIME
191196void CoTimerMgr::SetNextTriggerTime (SteadyTimePoint const & sdy_tp)
192197{
193198 steady_next_trigger_time_ = std::chrono::time_point_cast<std::chrono::milliseconds>(sdy_tp).time_since_epoch ().count ();
194199}
200+ #endif
195201
196202} // namespace co
Original file line number Diff line number Diff line change 66#include < vector>
77#include < list>
88#include " spinlock.h"
9+ #include " config.h"
910
1011namespace co
1112{
1213
1314class CoTimer ;
1415typedef std::shared_ptr<CoTimer> CoTimerPtr;
1516
16- typedef std::chrono::time_point<std::chrono::system_clock> SystemTimePoint;
17- typedef std::chrono::time_point<std::chrono::steady_clock> SteadyTimePoint;
17+ typedef std::chrono::system_clock::time_point SystemTimePoint;
18+ typedef std::chrono::steady_clock::time_point SteadyTimePoint;
1819
1920class CoTimer
2021{
@@ -64,7 +65,9 @@ class CoTimerMgr
6465
6566 CoTimerPtr ExpireAt (SystemTimePoint const & time_point, CoTimer::fn_t const & fn);
6667
68+ #ifndef UNSUPPORT_STEADY_TIME
6769 CoTimerPtr ExpireAt (SteadyTimePoint const & time_point, CoTimer::fn_t const & fn);
70+ #endif
6871
6972 template <typename Duration>
7073 CoTimerPtr ExpireAt (Duration const & duration, CoTimer::fn_t const & fn)
@@ -89,7 +92,10 @@ class CoTimerMgr
8992 long long GetNextTriggerTime ();
9093
9194 void SetNextTriggerTime (SystemTimePoint const & sys_tp);
95+
96+ #ifndef UNSUPPORT_STEADY_TIME
9297 void SetNextTriggerTime (SteadyTimePoint const & sdy_tp);
98+ #endif
9399
94100private:
95101 SystemDeadLines system_deadlines_;
You can’t perform that action at this time.
0 commit comments