xtd 0.2.0
Loading...
Searching...
No Matches
timer.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "timer_callback.hpp"
6#include "../core_export.hpp"
7#include "../object.hpp"
8#include "../time_span.hpp"
9#include "../types.hpp"
10
12namespace xtd {
14 namespace threading {
49 class core_export_ timer final : public object {
50 struct data;
51 public:
53
59 explicit timer(const timer_callback& callback);
66 timer(const timer_callback& callback, int32 due_time, int32 period);
73 timer(const timer_callback& callback, int64 due_time, int64 period);
80 timer(const timer_callback& callback, const time_span& due_time, const time_span& period);
87 timer(const timer_callback& callback, uint32 due_time, uint32 period);
95 timer(const timer_callback& callback, const xtd::any_object& state, int32 due_time, int32 period);
103 timer(const timer_callback& callback, const xtd::any_object& state, int64 due_time, int64 period);
111 timer(const timer_callback& callback, const xtd::any_object& state, const time_span& due_time, const time_span& period);
119 timer(const timer_callback& callback, const xtd::any_object& state, uint32 due_time, uint32 period);
121
123 template<class callback_t>
124 timer(callback_t callback) : timer(timer_callback {callback}) {}
125 template<class callback_t>
126 timer(callback_t callback, int32 due_time, int32 period) : timer(timer_callback {callback}, due_time, period) {}
127 template<class callback_t>
128 timer(callback_t callback, int64 due_time, int64 period) : timer(timer_callback {callback}, due_time, period) {}
129 template<class callback_t>
130 timer(callback_t callback, const time_span& due_time, const time_span& period) : timer(timer_callback {callback}, due_time, period) {}
131 template<class callback_t>
132 timer(callback_t callback, uint32 due_time, uint32 period) : timer(timer_callback {callback}, due_time, period) {}
133 template<class callback_t>
134 timer(callback_t callback, const xtd::any_object& state, int32 due_time, int32 period) : timer(timer_callback {callback}, due_time, period) {}
135 template<class callback_t>
136 timer(callback_t callback, const xtd::any_object& state, int64 due_time, int64 period) : timer(timer_callback {callback}, due_time, period) {}
137 template<class callback_t>
138 timer(callback_t callback, const xtd::any_object& state, const time_span& due_time, const time_span& period) : timer(timer_callback {callback}, due_time, period) {}
139 template<class callback_t>
140 timer(callback_t callback, const xtd::any_object& state, uint32 due_time, uint32 period) : timer(timer_callback {callback}, due_time, period) {}
141 timer();
142 timer(const timer& timer);
143 timer& operator=(const timer& timer);
144 ~timer();
146
148
154 void change(int32 due_time, int32 period);
159 void change(int64 due_time, int64 period);
164 void change(const time_span& due_time, const time_span& period);
169 void change(uint32 due_time, uint32 period);
170
172 void close();
174
175 private:
176 xtd::sptr<data> data_;
177 };
178 }
179}
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:29
object()=default
Create a new instance of the ultimate base class object.
Provides a mechanism for executing a method on a thread pool thread at specified intervals....
Definition timer.hpp:49
void change(int64 due_time, int64 period)
changes the start time and the interval between method invocations for a timer, using 64-bit signed i...
timer(const timer_callback &callback, int32 due_time, int32 period)
Initializes a new instance of the timer class, using a 32-bit signed integer to specify the time inte...
timer(const timer_callback &callback, int64 due_time, int64 period)
Initializes a new instance of the timer class, using a 64-bit signed integer to specify the time inte...
void change(int32 due_time, int32 period)
changes the start time and the interval between method invocations for a timer, using 32-bit signed i...
void change(uint32 due_time, uint32 period)
changes the start time and the interval between method invocations for a timer, using 32-bit unsigned...
timer(const timer_callback &callback, const xtd::any_object &state, int64 due_time, int64 period)
Initializes a new instance of the timer class, using a 64-bit signed integer to specify the time inte...
timer(const timer_callback &callback, const xtd::any_object &state, int32 due_time, int32 period)
Initializes a new instance of the timer class, using a 32-bit signed integer to specify the time inte...
timer(const timer_callback &callback, const xtd::any_object &state, uint32 due_time, uint32 period)
Initializes a new instance of the timer class, using a 32-bit unsigned integer to specify the time in...
timer(const timer_callback &callback, uint32 due_time, uint32 period)
Initializes a new instance of the timer class, using a 32-bit unsigned integer to specify the time in...
void change(const time_span &due_time, const time_span &period)
changes the start time and the interval between method invocations for a timer, using time_span value...
timer(const timer_callback &callback, const xtd::any_object &state, const time_span &due_time, const time_span &period)
Initializes a new instance of the timer class, using a TimaSpan to specify the time interval.
timer(const timer_callback &callback, const time_span &due_time, const time_span &period)
Initializes a new instance of the timer class, using a TimaSpan to specify the time interval.
timer(const timer_callback &callback)
Initializes a new instance of the timer class with an infinite period and an infinite due time,...
void close()
Releases all resources used by the current instance of xtd::threading::timer.
Represents a time interval.
Definition time_span.hpp:29
Contains core_export_ keyword.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
std::int64_t int64
Represents a 64-bit signed integer.
Definition int64.hpp:23
std::uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
action< const xtd::any_object & > timer_callback
Represents the method that handles calls from a xtd::threading::timer.
Definition timer_callback.hpp:28
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
Contains xtd::object class.
Contains xtd::time_span class.
Contains xtd::threading::timer_callback exception.
Contains xtd fundamental types.