use select for sleep instead of nanosleep for portability reasons

    added make of mgmapi_logevent_example
parent e33633c1
......@@ -4,7 +4,8 @@ BIN_DIRS := ndbapi_simple_example \
ndbapi_retries_example \
ndbapi_simple_index_example \
ndbapi_event_example \
ndbapi_scan_example
ndbapi_scan_example \
mgmapi_logevent_example
bins: $(patsubst %, _bins_%, $(BIN_DIRS))
......
......@@ -57,16 +57,15 @@
/**
* Helper sleep function
*/
int
static void
milliSleep(int milliseconds){
int result = 0;
struct timespec sleeptime;
struct timeval sleeptime;
sleeptime.tv_sec = milliseconds / 1000;
sleeptime.tv_nsec = (milliseconds - (sleeptime.tv_sec * 1000)) * 1000000;
result = nanosleep(&sleeptime, NULL);
return result;
sleeptime.tv_usec = (milliseconds - (sleeptime.tv_sec * 1000)) * 1000000;
select(0, 0, 0, 0, &sleeptime);
}
/**
* error printout macro
*/
......
......@@ -72,18 +72,17 @@
#include <NdbApi.hpp>
// Used for cout
#include <iostream>
#include <stdio.h>
/**
* Helper sleep function
*/
int
static void
milliSleep(int milliseconds){
int result = 0;
struct timespec sleeptime;
struct timeval sleeptime;
sleeptime.tv_sec = milliseconds / 1000;
sleeptime.tv_nsec = (milliseconds - (sleeptime.tv_sec * 1000)) * 1000000;
result = nanosleep(&sleeptime, NULL);
return result;
sleeptime.tv_usec = (milliseconds - (sleeptime.tv_sec * 1000)) * 1000000;
select(0, 0, 0, 0, &sleeptime);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment