mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 13:12:03 +00:00
some time changes
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6238 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
+6
-11
@@ -233,7 +233,13 @@ SWITCH_DECLARE(switch_status_t) switch_mutex_trylock(switch_mutex_t * lock)
|
||||
|
||||
SWITCH_DECLARE(switch_time_t) switch_time_now(void)
|
||||
{
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME,&ts);
|
||||
return ts.tv_sec * APR_USEC_PER_SEC + (ts.tv_nsec/1000);
|
||||
#else
|
||||
return (switch_time_t) apr_time_now();
|
||||
#endif
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt_get(switch_time_t * result, switch_time_exp_t * input)
|
||||
@@ -256,17 +262,6 @@ SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt(switch_time_exp_t * result,
|
||||
return apr_time_exp_gmt((apr_time_exp_t *) result, input);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_sleep(switch_interval_time_t t)
|
||||
{
|
||||
#if defined(HAVE_USLEEP)
|
||||
usleep(t);
|
||||
#elif defined(WIN32)
|
||||
Sleep((DWORD) ((t) / 1000));
|
||||
#else
|
||||
apr_sleep(t);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_rfc822_date(char *date_str, switch_time_t t)
|
||||
{
|
||||
|
||||
@@ -80,6 +80,29 @@ static timer_matrix_t TIMER_MATRIX[MAX_ELEMENTS + 1];
|
||||
#define IDLE_SPEED 100
|
||||
|
||||
|
||||
SWITCH_DECLARE(void) switch_sleep(switch_interval_time_t t)
|
||||
{
|
||||
|
||||
#if defined(HAVE_CLOCK_NANOSLEEP)
|
||||
struct timespec ts;
|
||||
ts.tv_sec = t / APR_USEC_PER_SEC;
|
||||
ts.tv_nsec = (t % APR_USEC_PER_SEC) * 1000;
|
||||
|
||||
clock_nanosleep(CLOCK_REALTIME, 0, &ts, NULL);
|
||||
|
||||
#elif defined(HAVE_USLEEP)
|
||||
usleep(t);
|
||||
#elif defined(WIN32)
|
||||
Sleep((DWORD) ((t) / 1000));
|
||||
#else
|
||||
apr_sleep(t);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static switch_status_t timer_init(switch_timer_t *timer)
|
||||
{
|
||||
timer_private_t *private_info;
|
||||
Reference in New Issue
Block a user