Skip to content

Instantly share code, notes, and snippets.

@pilcrow
Created March 16, 2011 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pilcrow/873189 to your computer and use it in GitHub Desktop.
Save pilcrow/873189 to your computer and use it in GitHub Desktop.
Firebird 2.1 FB_SLEEP UDF
/* 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