Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабы / 2 / lab.67.by mice / tube / src / tb_classes
.cpp/*******************************************************************************
* file: tb_classes.cpp *
* version: 0.0.1 *
* author: d-evil [tmd] (mailto:d-evil.tmd@mail.ru) *
* description: not available *
*******************************************************************************/
#include "tb_classes.h"
////////////////////////////////////////////////////////////////////////////////
// ctb_timeout public definitions
ctb_timeout::ctb_timeout(const clock_t to, const clock_t start) {
set(to, start);
}
ctb_timeout::~ctb_timeout() {
// dummy
}
void ctb_timeout::set(const clock_t to, const clock_t start) {
if (0 != to) _to = to;
_started = (0 != start)? start: clock();
}
void ctb_timeout::set_to(const clock_t to) {
_to = to;
}
clock_t ctb_timeout::elapsed() {
return clock() - _started;
}
bool ctb_timeout::out() {
return clock() > (_started + _to);
}
////////////////////////////////////////////////////////////////////////////////
// clock_t helper functions declaration
clock_t ms_to_clocks(const unsigned int t) {
return t * CLOCKS_PER_SEC / 1000;
}
unsigned int clocks_to_ms(const clock_t cl) {
return cl / CLOCKS_PER_SEC * 1000;
}
Соседние файлы в папке src