Created
March 16, 2011 19:56
-
-
Save pilcrow/873189 to your computer and use it in GitHub Desktop.
Firebird 2.1 FB_SLEEP UDF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* FB_SLEEP() UDF - pause an FB thread for a number of seconds */ | |
/* Mike Pomraning 2011 for FB 2.1; this code is in the Public Domain */ | |
#include <sys/select.h> | |
/* | |
DECLARE EXTERNAL FUNCTION fb_sleep | |
DOUBLE PRECISION | |
RETURNS INTEGER BY VALUE | |
ENTRY_POINT 'UDF_fb_sleep' MODULE_NAME 'udf_fb_sleep'; | |
*/ | |
int UDF_fb_sleep(double *d) | |
{ | |
struct timeval tv; | |
tv.tv_sec = (time_t)*d; | |
tv.tv_usec = ((*d - (double)tv.tv_sec) * 1000000.0); | |
select(0, NULL, NULL, NULL, &tv); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment