static void timeout_toggle(DBusTimeout *timeout, void *data) { struct timeout *t; (void)data; lem_debug("timeout = %p, interval = %d, enabled = %s", (void *)timeout, dbus_timeout_get_interval(timeout), dbus_timeout_get_enabled(timeout) ? "true" : "false"); t = dbus_timeout_get_data(timeout); if (dbus_timeout_get_enabled(timeout)) { ev_tstamp interval = ((ev_tstamp)dbus_timeout_get_interval(timeout))/1000.0; if (ev_is_active(&t->ev)) ev_timer_stop(EV_G_ &t->ev); ev_timer_set(&t->ev, interval, interval); ev_timer_start(EV_G_ &t->ev); } else ev_timer_stop(EV_G_ &t->ev); }
static dbus_bool_t pcmk_dbus_timeout_add(DBusTimeout *timeout, void *data){ guint id = g_timeout_add(dbus_timeout_get_interval(timeout), pcmk_dbus_timeout_dispatch, timeout); crm_trace("Adding timeout %p (%ld)", timeout, dbus_timeout_get_interval(timeout)); if(id) { dbus_timeout_set_data(timeout, GUINT_TO_POINTER(id), NULL); } return TRUE; }
static dbus_bool_t add_timeout(DBusTimeout *t, void *data) { if (!dbus_timeout_get_enabled(t)) return TRUE; int ms = dbus_timeout_get_interval(t); if ( ms < 0 || ms > TIMEOUT_MAX_MS ) { ms = TIMEOUT_MAX_MS; if ( ms < 0 || ms > INT_MAX/2-1 ) { ms = INT_MAX/2-1; } } if ( ms < 1 ) { ms = 1; } struct timeval tnow = {0,0}; gettimeofday(&tnow, NULL); unsigned int tnowms = TIME_TV_TO_MS(tnow); printf(" TIMEOUT: add dbus timeout %p value %u ms\n", t, ms); watched_timeout_start_tv = tnow; watched_timeout_setv = ms; watched_timeout_lastv = tnowms; watched_timeout = t; watched_chgevt_send( CHGEVT_ADD_TIMEOUT ); return TRUE; }
/** * UpdateTimeouts() updates the remaining time for each timeout and * returns how much time is left until the next timeout. * * This function must be called with p_sys->lock locked * * @return int The time remaining until the next timeout, in milliseconds * or -1 if there are no timeouts * * @param intf_thread_t *p_intf This interface thread's state * @param mtime_t i_loop_interval The time which has elapsed since the last * call to this function */ static int UpdateTimeouts( intf_thread_t *p_intf, mtime_t i_loop_interval ) { intf_sys_t *p_sys = p_intf->p_sys; mtime_t i_next_timeout = LAST_MDATE; unsigned int i_timeouts = vlc_array_count( p_sys->p_timeouts ); if( 0 == i_timeouts ) return -1; for( unsigned int i = 0; i < i_timeouts; i++ ) { timeout_info_t *p_info = NULL; DBusTimeout *p_timeout = NULL; mtime_t i_interval = 0; p_timeout = vlc_array_item_at_index( p_sys->p_timeouts, i ); i_interval = dbus_timeout_get_interval( p_timeout ) * 1000; /* µs */ p_info = (timeout_info_t*) dbus_timeout_get_data( p_timeout ); p_info->i_remaining -= __MAX( 0, i_loop_interval ) % i_interval; if( !dbus_timeout_get_enabled( p_timeout ) ) continue; /* The correct poll timeout value is the shortest one * in the dbus timeouts list */ i_next_timeout = __MIN( i_next_timeout, __MAX( 0, p_info->i_remaining ) ); } /* next timeout in milliseconds */ return i_next_timeout / 1000; }
static dbus_bool_t add_timeout(DBusTimeout *dbus_timeout, void *userdata) { TimeoutData *timeout; ConnectionData *d = userdata; struct timeval tv; dbus_bool_t b; assert(dbus_timeout); assert(d); if (!(timeout = avahi_new(TimeoutData, 1))) return FALSE; timeout->dbus_timeout = dbus_timeout; timeout->poll_api = d->poll_api; timeout->ref = 1; if ((b = dbus_timeout_get_enabled(dbus_timeout))) avahi_elapse_time(&tv, dbus_timeout_get_interval(dbus_timeout), 0); if (!(timeout->avahi_timeout = d->poll_api->timeout_new( d->poll_api, b ? &tv : NULL, timeout_callback, timeout))) { avahi_free(timeout); return FALSE; } dbus_timeout_set_data(dbus_timeout, timeout, (DBusFreeFunction) timeout_data_unref); return TRUE; }
static dbus_bool_t addTimeout(DBusTimeout *timeout, void *data) { (void)data; dbus_bool_t ret = FALSE; if(ARRAY_SIZE(gPollInfo.fds) > (unsigned int)(gPollInfo.nfds)) { const int interval = dbus_timeout_get_interval(timeout); if ((0<interval)&&(TRUE==dbus_timeout_get_enabled(timeout))) { const int tfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); if (-1!=tfd) { const struct itimerspec its = { .it_value= {interval/1000, interval%1000} }; if (-1!=timerfd_settime(tfd, 0, &its, NULL)) { tObjectEntry * const pEntry = &gPollInfo.objects[gPollInfo.nfds]; pEntry->objtype = OT_TIMEOUT; pEntry->timeout = timeout; gPollInfo.fds[gPollInfo.nfds].fd = tfd; gPollInfo.fds[gPollInfo.nfds].events |= POLLIN; ++gPollInfo.nfds; ret = TRUE; } else { DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("addTimeout - _settime() failed"), DLT_STRING(strerror(errno)) ); } } else { DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("addTimeout - _create() failed"), DLT_STRING(strerror(errno)) ); } } }
static void asdbus_set_dbus_timer (struct timeval *expires, DBusTimeout *timeout) { int interval = dbus_timeout_get_interval(timeout); gettimeofday (expires, NULL); tv_add_ms(expires, interval); show_debug(__FILE__,__FUNCTION__,__LINE__,"time = %d, adding dbus timeout data=%p, interval = %d\n", time(NULL), timeout, interval); timer_new (interval, asdbus_handle_timer, timeout); }
void DBusTimeout::recalculateDueTime() { if(dbus_timeout_get_enabled(libdbusTimeout_)) { unsigned int intervalInMs = dbus_timeout_get_interval(libdbusTimeout_); dueTimeInMs_ = getCurrentTimeInMs() + intervalInMs; } else { dueTimeInMs_ = TIMEOUT_INFINITE; } }
//utility int adjustTimeout(DBusTimeout* timeout, wl_event_source* source) { unsigned long iv = 0; if (dbus_timeout_get_enabled(timeout)) iv = dbus_timeout_get_interval(timeout); return wl_event_source_timer_update(source, iv); }
dbus_bool_t DBus_AddTimeout(DBusTimeout *timeout, void *data) { Tcl_TimerToken token; token = Tcl_CreateTimerHandler(dbus_timeout_get_interval(timeout), DBus_Timeout, timeout); dbus_timeout_set_data(timeout, token, NULL); return TRUE; }
static int weston_dbus_adjust_timeout(DBusTimeout *timeout, struct wl_event_source *s) { int64_t t = 0; if (dbus_timeout_get_enabled(timeout)) t = dbus_timeout_get_interval(timeout); return wl_event_source_timer_update(s, t); }
static dbus_bool_t edbus_add_timeout(DBusTimeout* timeout, void* data) { E_ASSERT(timeout != NULL); /* D-Bus interval sees in miliseconds, but FLTK see it in seconds */ int interval = dbus_timeout_get_interval(timeout); /* E_DEBUG(E_STRLOC ": added timeout to %i ms\n", interval); */ Fl::add_timeout(interval / 1000, timeout_cb, data); return 1; }
static int ldbus_timeout_get_interval(lua_State *L) { DBusTimeout *timeout = check_DBusTimeout(L, 1); int interval; if (timeout == NULL) { lua_pushnil(L); } else { interval = dbus_timeout_get_interval(timeout); lua_pushnumber(L, ((double)interval)/1000); } return 1; }
static void connection_setup_add_timeout(struct ctrl_iface_dbus_priv *iface, DBusTimeout *timeout) { if (!dbus_timeout_get_enabled(timeout)) return; eloop_register_timeout(0, dbus_timeout_get_interval(timeout) * 1000, process_timeout, iface, timeout); dbus_timeout_set_data(timeout, iface, NULL); }
/** * Callback for adding D-Bus timeout. */ static dbus_bool_t cdbus_callback_add_timeout(DBusTimeout *timeout, void *data) { session_t *ps = data; timeout_t *ptmout = timeout_insert(ps, dbus_timeout_get_interval(timeout), cdbus_callback_handle_timeout, timeout); if (ptmout) dbus_timeout_set_data(timeout, ptmout, NULL); return (bool) ptmout; }
/** * Callback for toggling a D-Bus timeout. */ static void cdbus_callback_timeout_toggled(DBusTimeout *timeout, void *data) { timeout_t *ptmout = dbus_timeout_get_data(timeout); assert(ptmout); if (ptmout) { ptmout->enabled = dbus_timeout_get_enabled(timeout); // Refresh interval as libdbus doc says: "Whenever a timeout is toggled, // its interval may change." ptmout->interval = dbus_timeout_get_interval(timeout); } }
static dbus_bool_t add_timeout(DBusTimeout *timeout, void *data) { struct wpas_dbus_priv *priv = data; if (!dbus_timeout_get_enabled(timeout)) return TRUE; eloop_register_timeout(0, dbus_timeout_get_interval(timeout) * 1000, process_timeout, priv, timeout); dbus_timeout_set_data(timeout, priv, NULL); return TRUE; }
static void update_timeout(TimeoutData *timeout) { assert(timeout); assert(timeout->ref >= 1); if (dbus_timeout_get_enabled(timeout->dbus_timeout)) { struct timeval tv; avahi_elapse_time(&tv, dbus_timeout_get_interval(timeout->dbus_timeout), 0); timeout->poll_api->timeout_update(timeout-> avahi_timeout, &tv); } else timeout->poll_api->timeout_update(timeout->avahi_timeout, NULL); }
static void toggle_timeout(DBusTimeout *to, void *data) { intf_thread_t *intf = data; intf_sys_t *sys = intf->p_sys; mtime_t *expiry = dbus_timeout_get_data(to); vlc_mutex_lock(&sys->lock); if (dbus_timeout_get_enabled(to)) *expiry = mdate() + UINT64_C(1000) * dbus_timeout_get_interval(to); vlc_mutex_unlock(&sys->lock); wakeup_main_loop(intf); }
dbus_bool_t timeout_add( DBusTimeout *timeout, void *data ) { int esi; /* phantom */ TimeoutHandler *handler; if ( dbus_timeout_get_enabled( &timeout ) ) { *(int*)(malloc( 12 )) = timeout; *(int*)malloc( 12 )/*.8*/ = dbus_timeout_get_interval( &timeout ); gui->add_timer( ebp_12, timeout_handler_cb, malloc( 12 ) + 8, malloc( 12 ) ); *(int*)malloc( 12 )/*.4*/ = ebp_12; dbus_timeout_set_data( &timeout, malloc( 12 ), &timeout_handler_dbus_freed ); } return 1; }
static dbus_bool_t timeout_add(DBusTimeout *timeout, void *data) { struct timeout *t; ev_tstamp interval = dbus_timeout_get_interval(timeout); lem_debug("timeout = %p, interval = %d, enabled = %s", (void *)timeout, dbus_timeout_get_interval(timeout), dbus_timeout_get_enabled(timeout) ? "true" : "false"); t = lem_xmalloc(sizeof(struct timeout)); interval = ((ev_tstamp)dbus_timeout_get_interval(timeout))/1000.0; ev_timer_init(&t->ev, timeout_handler, interval, interval); t->conn = data; t->timeout = timeout; dbus_timeout_set_data(timeout, t, NULL); if (dbus_timeout_get_enabled(timeout)) ev_timer_start(EV_G_ &t->ev); return TRUE; }
static void timeout_remove(DBusTimeout *timeout, void *data) { struct timeout *t; (void)data; lem_debug("timeout = %p, interval = %d, enabled = %s", (void *)timeout, dbus_timeout_get_interval(timeout), dbus_timeout_get_enabled(timeout) ? "true" : "false"); t = dbus_timeout_get_data(timeout); ev_timer_stop(EV_G_ &t->ev); free(t); }
static dbus_bool_t add_timeout(DBusTimeout *timeout, void *data) { timeout_handler_t *handler; if (!dbus_timeout_get_enabled(timeout)) return TRUE; handler = g_new0(timeout_handler_t, 1); handler->timeout = timeout; handler->id = g_timeout_add(dbus_timeout_get_interval(timeout), timeout_handler_dispatch, handler); dbus_timeout_set_data(timeout, handler, timeout_handler_free); return TRUE; }
static dbus_bool_t add_timeout( DBusTimeout *p_timeout, void *p_data ) { intf_thread_t *p_intf = (intf_thread_t*) p_data; intf_sys_t *p_sys = (intf_sys_t*) p_intf->p_sys; timeout_info_t *p_info = calloc( 1, sizeof( timeout_info_t ) ); p_info->i_remaining = dbus_timeout_get_interval( p_timeout ) * 1000;/* µs */ p_info->p_timeout = p_timeout; dbus_timeout_set_data( p_timeout, p_info, free ); vlc_mutex_lock( &p_sys->lock ); vlc_array_append( p_sys->p_timeouts, p_timeout ); vlc_mutex_unlock( &p_sys->lock ); return TRUE; }
static int timeout_arm(EpollData *e) { struct itimerspec its; assert(e); assert(e->is_timeout); zero(its); if (dbus_timeout_get_enabled(e->object)) { timespec_store(&its.it_value, dbus_timeout_get_interval(e->object) * USEC_PER_MSEC); its.it_interval = its.it_value; } if (timerfd_settime(e->fd, 0, &its, NULL) < 0) return -errno; return 0; }
/* pa_time_event_cb_t timer event handler */ static void handle_time_event(pa_mainloop_api *ea, pa_time_event* e, const struct timeval *t, void *userdata) { struct timeval tv; struct timeout_data *d = userdata; pa_assert(d); pa_assert(d->connection); if (dbus_timeout_get_enabled(d->timeout)) { /* Restart it for the next scheduled time. We do this before * calling dbus_timeout_handle() to make sure that the time * event is still around. */ ea->time_restart(e, pa_timeval_rtstore(&tv, pa_timeval_load(t) + dbus_timeout_get_interval(d->timeout) * PA_USEC_PER_MSEC, d->connection->use_rtclock)); dbus_timeout_handle(d->timeout); } }
static dbus_bool_t efl_dbus_timeout_add(DBusTimeout *timeout, void *data) { struct timeout_handler *to_handler; if (dbus_timeout_get_enabled(timeout) == FALSE) return TRUE; to_handler = calloc(1, sizeof(struct timeout_handler)); if (to_handler == NULL) return FALSE; dbus_timeout_set_data(timeout, to_handler, timeout_handler_free); to_handler->e_timer = ecore_timer_add( dbus_timeout_get_interval(timeout), timeout_handler_dispatch, to_handler); return TRUE; }
static void connection_setup_add_timeout (ConnectionSetup *cs, DBusTimeout *timeout) { TimeoutHandler *handler; if (!dbus_timeout_get_enabled (timeout)) return; g_assert (dbus_timeout_get_data (timeout) == NULL); handler = g_new0 (TimeoutHandler, 1); handler->cs = cs; handler->timeout = timeout; handler->source = g_timeout_source_new (dbus_timeout_get_interval (timeout)); g_source_set_callback (handler->source, timeout_handler_dispatch, handler, timeout_handler_source_finalized); g_source_attach (handler->source, handler->cs->context); cs->timeouts = g_slist_prepend (cs->timeouts, handler); dbus_timeout_set_data (timeout, handler, timeout_handler_timeout_freed); }
/** * ProcessTimeouts() handles DBus timeouts * * This function must be called with p_sys->lock locked * * @param intf_thread_t *p_intf This interface thread state * @param DBusTimeout **p_timeouts List of timeouts to process * @param int i_timeouts Size of p_timeouts */ static void ProcessTimeouts( intf_thread_t *p_intf, DBusTimeout **p_timeouts, int i_timeouts ) { VLC_UNUSED( p_intf ); for( int i = 0; i < i_timeouts; i++ ) { timeout_info_t *p_info = NULL; p_info = (timeout_info_t*) dbus_timeout_get_data( p_timeouts[i] ); if( !dbus_timeout_get_enabled( p_info->p_timeout ) ) continue; if( p_info->i_remaining > 0 ) continue; dbus_timeout_handle( p_info->p_timeout ); p_info->i_remaining = dbus_timeout_get_interval( p_info->p_timeout ); } }
static dbus_bool_t timeout_add (DBusTimeout * timeout, void *data) { TimeoutHandler *handler; hidval temp; // We won't create a timeout until it becomes enabled. if (!dbus_timeout_get_enabled (timeout)) { return TRUE; } //FIXME: Need to store the interval, as PCB requires us // to manually re-add the timer each time it expires. // This is non-ideal, and hopefully can be changed? handler = (TimeoutHandler *)malloc (sizeof (TimeoutHandler)); temp.ptr = (void *)handler; handler->dbus_timeout = timeout; handler->interval = dbus_timeout_get_interval (timeout); handler->pcb_timer = gui->add_timer (timeout_handler_cb, handler->interval, temp); dbus_timeout_set_data (timeout, handler, timeout_handler_dbus_freed); return TRUE; }