projects
/
NeonServV5.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[IOMultiplexer] added auto-reloading timers
[NeonServV5.git]
/
src
/
test
/
timer
/
iotest.c
diff --git
a/src/test/timer/iotest.c
b/src/test/timer/iotest.c
index 7ce2d44e6acc872b4ef0137b53b0840b06741274..17a91ecff13017a4967057330e57b421f8586c61 100644
(file)
--- a/
src/test/timer/iotest.c
+++ b/
src/test/timer/iotest.c
@@
-26,7
+26,7
@@
static IOHANDLER_LOG_BACKEND(io_log);
static struct timeval test_clock1, test_clock2;
static int timercount;
static struct timeval test_clock1, test_clock2;
static int timercount;
-
static
void add_timer(int ms) {
+void add_timer(int ms) {
struct timeval timeout;
gettimeofday(&timeout, NULL);
timeout.tv_usec += (ms % 1000) * 1000;
struct timeval timeout;
gettimeofday(&timeout, NULL);
timeout.tv_usec += (ms % 1000) * 1000;
@@
-45,7
+45,8
@@
int main(int argc, char *argv[]) {
gettimeofday(&test_clock1, NULL);
gettimeofday(&test_clock2, NULL);
gettimeofday(&test_clock1, NULL);
gettimeofday(&test_clock2, NULL);
- add_timer(TEST_DURATION);
+ //add_timer(TEST_DURATION);
+ iohandler_constant_timer(TEST_DURATION, io_callback);
timercount = 0;
printf("[timer 0] %ld.%ld\n", test_clock1.tv_sec, test_clock1.tv_usec);
timercount = 0;
printf("[timer 0] %ld.%ld\n", test_clock1.tv_sec, test_clock1.tv_usec);
@@
-61,7
+62,7
@@
static IOHANDLER_CALLBACK(io_callback) {
double diff2;
switch(event->type) {
case IOEVENT_TIMEOUT:
double diff2;
switch(event->type) {
case IOEVENT_TIMEOUT:
- add_timer(TEST_DURATION);
+
//
add_timer(TEST_DURATION);
timercount++;
gettimeofday(&curr_time, NULL);
diff1 = (curr_time.tv_sec - test_clock1.tv_sec) * 1000 + ((curr_time.tv_usec - test_clock1.tv_usec) / 1000);
timercount++;
gettimeofday(&curr_time, NULL);
diff1 = (curr_time.tv_sec - test_clock1.tv_sec) * 1000 + ((curr_time.tv_usec - test_clock1.tv_usec) / 1000);