|
22 | 22 | #include "platform/NonCopyable.h"
|
23 | 23 |
|
24 | 24 | namespace mbed {
|
| 25 | + |
| 26 | +class CriticalSectionLock; |
| 27 | + |
25 | 28 | /**
|
26 | 29 | * \defgroup drivers_Timer Timer class
|
27 | 30 | * \ingroup drivers-public-api-ticker
|
@@ -51,7 +54,7 @@ namespace mbed {
|
51 | 54 | * }
|
52 | 55 | * @endcode
|
53 | 56 | */
|
54 |
| -class TimerBase : private NonCopyable<TimerBase> { |
| 57 | +class TimerBase { |
55 | 58 |
|
56 | 59 | public:
|
57 | 60 | /** Start the timer
|
@@ -109,13 +112,24 @@ class TimerBase : private NonCopyable<TimerBase> {
|
109 | 112 | protected:
|
110 | 113 | TimerBase(const ticker_data_t *data);
|
111 | 114 | TimerBase(const ticker_data_t *data, bool lock_deepsleep);
|
| 115 | + TimerBase(const TimerBase &t); |
| 116 | + TimerBase(TimerBase &&t); |
112 | 117 | ~TimerBase();
|
| 118 | + |
| 119 | + const TimerBase &operator=(const TimerBase &) = delete; |
| 120 | + |
113 | 121 | std::chrono::microseconds slicetime() const;
|
114 | 122 | TickerDataClock::time_point _start{}; // the start time of the latest slice
|
115 | 123 | std::chrono::microseconds _time{}; // any accumulated time from previous slices
|
116 | 124 | TickerDataClock _ticker_data;
|
117 | 125 | bool _lock_deepsleep; // flag that indicates if deep sleep should be disabled
|
118 | 126 | bool _running = false; // whether the timer is running
|
| 127 | + |
| 128 | +private: |
| 129 | + // Copy storage while a lock is held |
| 130 | + TimerBase(const TimerBase &t, const CriticalSectionLock &) : TimerBase(t, false) {} |
| 131 | + // Copy storage only - used by delegating constructors |
| 132 | + TimerBase(const TimerBase &t, bool) : _start(t._start), _time(t._time), _ticker_data(t._ticker_data), _lock_deepsleep(t._lock_deepsleep), _running(t._running) {} |
119 | 133 | };
|
120 | 134 | #endif
|
121 | 135 |
|
|
0 commit comments