xtd 0.2.0
timer.h
Go to the documentation of this file.
1 #pragma once
5 #include "timer_callback.h"
6 #include "../core_export.h"
7 #include "../object.h"
8 #include "../time_span.h"
9 #include "../types.h"
10 
12 namespace xtd {
14  namespace threading {
47  class core_export_ timer final : public object {
48  struct data;
49  public:
51 
58  explicit timer(const timer_callback& callback);
66  timer(const timer_callback& callback, int32 due_time, int32 period);
74  timer(const timer_callback& callback, int64 due_time, int64 period);
82  timer(const timer_callback& callback, const time_span& due_time, const time_span& period);
90  timer(const timer_callback& callback, uint32 due_time, uint32 period);
99  timer(const timer_callback& callback, std::any state, int32 due_time, int32 period);
108  timer(const timer_callback& callback, std::any state, int64 due_time, int64 period);
117  timer(const timer_callback& callback, std::any state, const time_span& due_time, const time_span& period);
126  timer(const timer_callback& callback, std::any state, uint32 due_time, uint32 period);
128 
130  template <typename callback_t>
131  timer(callback_t callback) : timer(timer_callback {callback}) {}
132  template <typename callback_t>
133  timer(callback_t callback, int32 due_time, int32 period) : timer(timer_callback {callback}, due_time, period) {}
134  template <typename callback_t>
135  timer(callback_t callback, int64 due_time, int64 period) : timer(timer_callback {callback}, due_time, period) {}
136  template <typename callback_t>
137  timer(callback_t callback, const time_span& due_time, const time_span& period) : timer(timer_callback {callback}, due_time, period) {}
138  template <typename callback_t>
139  timer(callback_t callback, uint32 due_time, uint32 period) : timer(timer_callback {callback}, due_time, period) {}
140  template <typename callback_t>
141  timer(callback_t callback, std::any state, int32 due_time, int32 period) : timer(timer_callback {callback}, due_time, period) {}
142  template <typename callback_t>
143  timer(callback_t callback, std::any state, int64 due_time, int64 period) : timer(timer_callback {callback}, due_time, period) {}
144  template <typename callback_t>
145  timer(callback_t callback, std::any state, const time_span& due_time, const time_span& period) : timer(timer_callback {callback}, due_time, period) {}
146  template <typename callback_t>
147  timer(callback_t callback, std::any state, uint32 due_time, uint32 period) : timer(timer_callback {callback}, due_time, period) {}
148  timer();
149  timer(const timer& timer);
150  timer& operator=(const timer& timer);
151  ~timer();
153 
155 
161  void change(int32 due_time, int32 period);
166  void change(int64 due_time, int64 period);
172  void change(const time_span& due_time, const time_span& period);
177  void change(uint32 due_time, uint32 period);
178 
180  void close();
182 
183  private:
184  std::shared_ptr<data> data_;
185  };
186  }
187 }
Provides a mechanism for executing a method on a thread pool thread at specified intervals. This class cannot be inherited.
Definition: timer.h:47
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Contains xtd::threading::timer_callback exception.
Indicates that all styles except allow_binary_specifier, allow_octal_specifier and allow_hex_specifie...
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
Represents a time interval.
Definition: time_span.h:26
int_least32_t int32
Represents a 32-bit signed integer.
Definition: types.h:129
action< std::any > timer_callback
Represents the method that handles calls from a xtd::threading::timer.
Definition: timer_callback.h:26
int_least64_t int64
Represents a 64-bit signed integer.
Definition: types.h:140
uint_least32_t uint32
Represents a 32-bit unsigned integer.
Definition: types.h:239