Change interface, more logical naming
This commit is contained in:
		| @@ -40,18 +40,18 @@ sc::timer::~timer() { | |||||||
|     timer_delete(_tid); |     timer_delete(_tid); | ||||||
| } | } | ||||||
|  |  | ||||||
| void sc::timer::time(struct itimerspec& cur_value) const { | void sc::timer::time_left(struct itimerspec& cur_value) const { | ||||||
|     throw_if_min1_msg(timer_gettime(_tid, &cur_value), "could not get time"); |     throw_if_min1_msg(timer_gettime(_tid, &cur_value), "could not get time"); | ||||||
| } | } | ||||||
|  |  | ||||||
| double sc::timer::time() const { | double sc::timer::time_left() const { | ||||||
|     struct itimerspec its; |     struct itimerspec its; | ||||||
|     time(its); |     time_left(its); | ||||||
|     return its.it_value.tv_sec + its.it_value.tv_nsec * 1000000000; |     return its.it_value.tv_sec + its.it_value.tv_nsec * 1000000000; | ||||||
| } | } | ||||||
|  |  | ||||||
| bool sc::timer::is_armed() const { | bool sc::timer::is_armed() const { | ||||||
|     struct itimerspec its; |     struct itimerspec its; | ||||||
|     time(its); |     time_left(its); | ||||||
|     return its.it_value.tv_sec != 0 || its.it_value.tv_nsec != 0; |     return its.it_value.tv_sec != 0 || its.it_value.tv_nsec != 0; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -19,8 +19,9 @@ namespace sc { | |||||||
|             timer(void(*callback)(union sigval), double time, bool repeat = false); |             timer(void(*callback)(union sigval), double time, bool repeat = false); | ||||||
|             ~timer(); |             ~timer(); | ||||||
|  |  | ||||||
|             void time(struct itimerspec& cur_value) const; |             void time_left(struct itimerspec& cur_value) const; | ||||||
|             double time() const; |             double time_left() const; | ||||||
|  |             double time() const { return _time; } | ||||||
|             bool is_armed() const; |             bool is_armed() const; | ||||||
|             bool repeat() const { return _repeat; } |             bool repeat() const { return _repeat; } | ||||||
|     }; |     }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user