void soundmenu_update_playback_lastfm (SoundmenuPlugin *soundmenu) { Mpris2Metadata *metadata = NULL; LastfmData *data1 = NULL, *data2 = NULL; gint length, delay_time; time_t started_t; SoundmenuLastfm *lastfm = soundmenu->clastfm; if (lastfm->scroble_handler_id) { g_source_remove (lastfm->scroble_handler_id); lastfm->scroble_handler_id = 0; } if (lastfm->update_handler_id) { g_source_remove (lastfm->update_handler_id); lastfm->update_handler_id = 0; } if (mpris2_client_get_playback_status (soundmenu->mpris2) != PLAYING) return; if (lastfm->status != LASTFM_STATUS_OK) return; metadata = mpris2_client_get_metadata (soundmenu->mpris2); if (g_str_empty0(mpris2_metadata_get_artist(metadata)) || g_str_empty0(mpris2_metadata_get_album(metadata))) return; length = mpris2_metadata_get_length (metadata); if (length < 30) return; time (&started_t); data1 = soundmenu_lastfm_data_new (soundmenu, metadata, started_t); lastfm->update_handler_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE, WAIT_UPDATE, soundmenu_lastfm_now_playing_handler, data1, NULL); data2 = soundmenu_lastfm_data_new (soundmenu, metadata, started_t); delay_time = ((length / 2) > 240) ? 240 : (length / 2); lastfm->scroble_handler_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE, delay_time, soundmenu_lastfm_scrobble_handler, data2, NULL); }
/** * g_vfs_ftp_connection_accept_data_connection: * @conn: a listening connection * @cancellable: cancellable to interrupt wait * @error: %NULL or location to take a potential error * * Opens a data connection for @conn by accepting an incoming connection on the * address it is listening on via g_vfs_ftp_connection_listen_data_connection(), * which must have been called prior to this function. * If this function succeeds, a data connection will have been opened, and calls * to g_vfs_ftp_connection_get_data_stream() will work. * * Returns: %TRUE if a connection was successfully acquired **/ gboolean g_vfs_ftp_connection_accept_data_connection (GVfsFtpConnection *conn, GCancellable * cancellable, GError ** error) { GSocket *accepted; GCancellable *timer; gulong cancel_cb_id; GIOCondition condition; g_return_val_if_fail (conn != NULL, FALSE); g_return_val_if_fail (conn->data == NULL, FALSE); g_return_val_if_fail (G_IS_SOCKET (conn->listen_socket), FALSE); timer = g_cancellable_new (); cancel_cb_id = g_cancellable_connect (cancellable, G_CALLBACK (cancel_timer_cb), timer, NULL); g_object_ref (timer); g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, G_VFS_FTP_TIMEOUT_IN_SECONDS, cancel_cancellable, timer, g_object_unref); condition = g_socket_condition_wait (conn->listen_socket, G_IO_IN, timer, error); g_cancellable_disconnect (cancellable, cancel_cb_id); g_object_unref (timer); if ((condition & G_IO_IN) == 0) { if (g_cancellable_is_cancelled (timer) && !g_cancellable_is_cancelled (cancellable)) { g_clear_error (error); g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_HOST_NOT_FOUND, _("Failed to create active FTP connection. " "Maybe your router does not support this?")); } else if (error && *error == NULL) { g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_HOST_NOT_FOUND, _("Failed to create active FTP connection.")); } return FALSE; } accepted = g_socket_accept (conn->listen_socket, cancellable, error); if (accepted == NULL) return FALSE; conn->data = G_IO_STREAM (g_socket_connection_factory_create_connection (accepted)); g_object_unref (accepted); enable_nodelay (G_SOCKET_CONNECTION (conn->data)); return TRUE; }
static void photos_application_refresh_db (GObject *source_object, GAsyncResult *res, gpointer user_data) { PhotosApplication *self = PHOTOS_APPLICATION (user_data); PhotosApplicationPrivate *priv = self->priv; GError *error; GomMiner *miner = GOM_MINER (source_object); PhotosApplicationRefreshData *data; priv->miners_running = g_list_remove (priv->miners_running, miner); error = NULL; if (!gom_miner_call_refresh_db_finish (miner, res, &error)) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning ("Unable to update the cache: %s", error->message); g_error_free (error); goto out; } data = photos_application_refresh_data_new (self, miner); g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, MINER_REFRESH_TIMEOUT, photos_application_refresh_miner_timeout, data, (GDestroyNotify) photos_application_refresh_data_free); out: g_object_unref (self); g_object_unref (miner); }
static void mount_pre_removed_cb (GVolumeMonitor *monitor, GMount *mount, gpointer user_data) { TrackerStorage *storage; TrackerStoragePrivate *priv; UnmountCheckData *data; guint id; storage = user_data; priv = TRACKER_STORAGE_GET_PRIVATE (storage); mount_remove (storage, mount); /* Add check for failed unmounts */ data = g_new (UnmountCheckData, 1); data->storage = storage; data->mount = mount; id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE + 10, 3, unmount_failed_cb, data, (GDestroyNotify) g_free); g_hash_table_insert (priv->unmount_watchdogs, data->mount, GUINT_TO_POINTER (id)); }
void matecomponent_activation_postinit (gpointer app, gpointer mod_info) { matecomponent_activation_base_service_init (); #if defined (F_SETFD) && defined (FD_CLOEXEC) if (matecomponent_activation_ior_fd > 2) fcntl (matecomponent_activation_ior_fd, F_SETFD, FD_CLOEXEC); #endif #ifdef G_OS_WIN32 if (matecomponent_activation_ior_fd > 2) { HANDLE newhandle; if (DuplicateHandle (GetCurrentProcess (), (HANDLE) _get_osfhandle (matecomponent_activation_ior_fd), GetCurrentProcess (), &newhandle, 0, FALSE, DUPLICATE_SAME_ACCESS)) { close (matecomponent_activation_ior_fd); matecomponent_activation_ior_fd = _open_osfhandle ((int) newhandle, _O_TEXT | _O_NOINHERIT); } } #endif if (matecomponent_activation_activate_iid) g_timeout_add_seconds_full (G_PRIORITY_LOW, MATECOMPONENT_ACTIVATION_FACTORY_PRIVATE_TIMEOUT, matecomponent_activation_timeout_reg_check, NULL, NULL); else matecomponent_activation_timeout_reg_check_set (FALSE); is_initialized = TRUE; }
gboolean rb_plugins_engine_init (RBShell *shell) { g_return_val_if_fail (rb_plugins == NULL, FALSE); if (!g_module_supported ()) { g_warning ("rb is not able to initialize the plugins engine."); return FALSE; } rb_profile_start ("plugins engine init"); rb_plugins = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify)rb_plugin_info_free); rb_plugins_shell = shell; g_object_ref (G_OBJECT (rb_plugins_shell)); #ifdef ENABLE_PYTHON rb_python_module_init_python (); #endif rb_plugins_engine_load_all (); garbage_collect_id = g_timeout_add_seconds_full (G_PRIORITY_LOW, 20, garbage_collect_cb, NULL, NULL); rb_profile_end ("plugins engine init"); return TRUE; }
static void state_changed (NMVPNPlugin *plugin, NMVPNServiceState state) { NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin); switch (state) { case NM_VPN_SERVICE_STATE_STARTING: /* Remove the quit timer. */ if (priv->quit_timer) g_source_remove (priv->quit_timer); if (priv->fail_stop_id) { g_source_remove (priv->fail_stop_id); priv->fail_stop_id = 0; } /* Add a timer to make sure we do not wait indefinitely for the successful connect. */ priv->connect_timer = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, NM_VPN_PLUGIN_CONNECT_TIMER, connect_timer_expired, plugin, connect_timer_removed); break; case NM_VPN_SERVICE_STATE_STOPPED: priv->quit_timer = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, NM_VPN_PLUGIN_QUIT_TIMER, quit_timer_expired, plugin, quit_timer_removed); break; default: /* Clean up all timers we might have set up. */ if (priv->connect_timer) g_source_remove (priv->connect_timer); if (priv->quit_timer) g_source_remove (priv->quit_timer); if (priv->fail_stop_id) { g_source_remove (priv->fail_stop_id); priv->fail_stop_id = 0; } break; } }
static void schedule_reap_cache (void) { if (reap_cache_timeout == 0) { reap_cache_timeout = g_timeout_add_seconds_full (0, 5, reap_cache, NULL, NULL); } }
static void terminal_toolbars_model_queue_sync (TerminalToolbarsModel *model) { if (G_LIKELY (model->sync_id == 0)) { model->sync_id = g_timeout_add_seconds_full (G_PRIORITY_LOW, 1, terminal_toolbars_model_sync, model, terminal_toolbars_model_sync_destroy); } }
static void gm_sb_push_message (GmStatusbar *sb, gboolean flash_message, gboolean info_message, const char *msg, va_list args) { static guint timer_source; gint id = 0; gint msg_id = 0; #if GTK_CHECK_VERSION (2, 21, 2) #else int len = 0; int i = 0; #endif g_return_if_fail (sb != NULL); if (info_message) id = gtk_statusbar_get_context_id (GTK_STATUSBAR (sb), "info"); else id = gtk_statusbar_get_context_id (GTK_STATUSBAR (sb), "statusbar"); #if GTK_CHECK_VERSION (2, 21, 2) gtk_statusbar_remove_all (GTK_STATUSBAR (sb), id); #else len = g_slist_length ((GSList *) (GTK_STATUSBAR (sb)->messages)); for (i = 0 ; i < len ; i++) gtk_statusbar_pop (GTK_STATUSBAR (sb), id); #endif if (msg) { char buffer [1025]; g_vsnprintf (buffer, 1024, msg, args); msg_id = gtk_statusbar_push (GTK_STATUSBAR (sb), id, buffer); if (flash_message) { if (timer_source != 0) { g_source_remove (timer_source); timer_source = 0; } callback_info* info = g_new0 (callback_info, 1); info->statusbar = GTK_STATUSBAR (sb); info->msg_id = msg_id; timer_source = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, 15, gm_statusbar_clear_msg_cb, info, g_free); } } }
static void connect_timer_start (NMVPNPlugin *plugin) { NMVPNPluginPrivate *priv = NM_VPN_PLUGIN_GET_PRIVATE (plugin); priv->connect_timer = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, 60, connect_timer_expired, plugin, connect_timer_removed); }
void csd_allow_autorun_for_volume_finish (GVolume *volume) { if (g_object_get_data (G_OBJECT (volume), "csd-allow-autorun") != NULL) { g_timeout_add_seconds_full (0, INHIBIT_AUTORUN_SECONDS, remove_allow_volume, g_object_ref (volume), g_object_unref); } }
static gpointer queue_add_file(FmJob* fmjob, gpointer user_data) { FmDirListJob* job = FM_DIR_LIST_JOB(fmjob); FmFileInfo* file = FM_FILE_INFO(user_data); /* this callback is called from the main thread */ /* g_print("queue_add_file: %s\n", fm_file_info_get_disp_name(file)); */ job->files_to_add = g_slist_prepend(job->files_to_add, fm_file_info_ref(file)); if(job->delay_add_files_handler == 0) job->delay_add_files_handler = g_timeout_add_seconds_full(G_PRIORITY_LOW, 1, emit_found_files, g_object_ref(job), g_object_unref); return NULL; }
static void photos_preview_nav_buttons_queue_auto_hide (PhotosPreviewNavButtons *self) { PhotosPreviewNavButtonsPrivate *priv = self->priv; photos_preview_nav_buttons_unqueue_auto_hide (self); priv->auto_hide_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, 2, (GSourceFunc) photos_preview_nav_buttons_auto_hide, g_object_ref (self), g_object_unref); }
int main() { FfWriterEngine *Writer = new FfWriterEngine(); Log = new Logging("ff_test_mem.log", LOG_LEVEL); MainLoop = g_main_loop_new(NULL, FALSE); Writer->FirstStartRec(); g_timeout_add_seconds_full(1000, 1, TimeoutCallback, (gpointer) Writer, NULL); Memory = Writer->GetMemoryConsumption(); g_main_loop_run(MainLoop); delete Log; delete Writer; }
void nm_ip6_manager_begin_addrconf (NMIP6Manager *manager, int ifindex) { NMIP6ManagerPrivate *priv; NMIP6Device *device; CallbackInfo *info; g_return_if_fail (NM_IS_IP6_MANAGER (manager)); g_return_if_fail (ifindex > 0); priv = NM_IP6_MANAGER_GET_PRIVATE (manager); device = (NMIP6Device *) g_hash_table_lookup (priv->devices, GINT_TO_POINTER (ifindex)); g_return_if_fail (device != NULL); nm_log_info (LOGD_IP6, "Activation (%s) Beginning IP6 addrconf.", device->iface); device->addrconf_complete = FALSE; device->ra_flags = 0; /* Set up a timeout on the transaction to kill it after the timeout */ info = callback_info_new (device, FALSE); device->finish_addrconf_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, NM_IP6_TIMEOUT, finish_addrconf, info, (GDestroyNotify) g_free); /* Bounce IPv6 on the interface to ensure the kernel will start looking for * new RAs; there doesn't seem to be a better way to do this right now. */ if (device->target_state >= NM_IP6_DEVICE_GOT_ADDRESS) { nm_utils_do_sysctl (device->disable_ip6_path, "1"); /* Wait until all existing IPv6 addresses have been removed from the link, * to ensure they don't confuse our IPv6 addressing state machine. */ wait_for_no_addresses (manager, device); nm_utils_do_sysctl (device->disable_ip6_path, "0"); } device->ip6flags_poll_id = g_timeout_add_seconds (1, poll_ip6_flags, priv->monitor); /* Kick off the initial IPv6 flags request */ nm_netlink_monitor_request_ip6_info (priv->monitor, NULL); /* Sync flags, etc, from netlink; this will also notice if the * device is already fully configured and schedule the * ADDRCONF_COMPLETE signal in that case. */ nm_ip6_device_sync_from_netlink (device); }
void soundmenu_lastfm_init (SoundmenuLastfm *lastfm) { #if GLIB_CHECK_VERSION(2,32,0) if (g_network_monitor_get_network_available (g_network_monitor_get_default ())) #else if(nm_is_online () == TRUE) #endif g_idle_add (soundmenu_lastfm_connect_idle, lastfm); else g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE, 30, soundmenu_lastfm_connect_idle, lastfm, NULL); }
/** * tracker_media_art_queue_execute: * * Process all stored media art requests. * * Since: 0.10.4 */ void tracker_media_art_queue_empty (TrackerSparqlConnection *connection) { if (had_any && timer_id == 0) { timer_id = g_timeout_add_seconds_full (G_PRIORITY_LOW, 1800 /* Half an hour worth of seconds*/, on_timer_callback, g_object_ref (connection), on_timer_destroy); had_any = FALSE; } }
static void et_status_bar_start_timer (EtStatusBar *self) { EtStatusBarPrivate *priv; priv = et_status_bar_get_instance_private (self); et_status_bar_remove_timer (self); priv->timer_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, 4, (GSourceFunc)et_status_bar_stop_timer, self, (GDestroyNotify)et_status_bar_reset_timer); g_source_set_name_by_id (priv->timer_id, "Statusbar stop timer"); }
static void confirm_cb(GIOChannel *io, gpointer user_data) { char addr[18]; struct io_data *data = user_data; GError *err = NULL; if (!bt_io_get(io, &err, BT_IO_OPT_DEST, addr, BT_IO_OPT_INVALID)) { printf("bt_io_get(OPT_DEST): %s\n", err->message); g_clear_error(&err); } else printf("Got confirmation request for %s\n", addr); if (data->accept < 0 && data->reject < 0) return; if (data->reject == 0) { printf("Rejecting connection\n"); g_io_channel_shutdown(io, TRUE, NULL); return; } if (data->voice) { if (!bt_io_set(io, &err, BT_IO_OPT_VOICE, data->voice, BT_IO_OPT_INVALID)) { printf("bt_io_set(OPT_VOICE): %s\n", err->message); g_clear_error(&err); } } data->io = g_io_channel_ref(io); io_data_ref(data); if (data->accept == 0) { if (!bt_io_accept(io, connect_cb, data, (GDestroyNotify) io_data_unref, &err)) { printf("bt_io_accept() failed: %s\n", err->message); g_clear_error(&err); io_data_unref(data); return; } } else { int seconds = (data->reject > 0) ? data->reject : data->accept; g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, seconds, confirm_timeout, data, (GDestroyNotify) io_data_unref); } }
void MetadataManager::updateAccessTime(String uri) { XOJ_CHECK_TYPE(MetadataManager); // TODO LOW PRIO: newer GTK Version use _int64 instead of integer g_key_file_set_integer(this->config, uri.c_str(), "atime", time(NULL)); if (this->timeoutId) { return; } this->timeoutId = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT_IDLE, 2, (GSourceFunc) save, this, NULL); }
static void message_complete (SoupSession *sesison, SoupMessage *msg, gpointer user_data) { //g_print ("message_complete->enter\n"); MessageData *message_data = (MessageData *) user_data; static gint delay = 2; if (SOUP_STATUS_IS_SUCCESSFUL (message_data->msg->status_code) || SOUP_STATUS_IS_CLIENT_ERROR (message_data->msg->status_code)) { delay = 2; if (message_data->finish_callback) { message_data->finish_callback (message_data->session, message_data->msg, message_data->user_data); } g_slice_free (MessageData, message_data); //g_print ("message_complete->add message_handler\n"); g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, message_handler, NULL, NULL); } else { // failed to send message delay = (gint ) (delay * 1.5); // Don't wait more than 10 minutes between retries. if (delay > 625) { delay = 625; } gchar *uri = soup_uri_to_string(soup_message_get_uri(message_data->msg), TRUE); g_warning("%s: Unable to send %s, delaying %d seconds..", message_data->msg->reason_phrase, uri, delay); g_free(uri); // push it back onto the queue. (void)g_object_ref (message_data->msg); g_queue_push_head (message_queue, message_data); //g_print ("message_complete->add delay_handler\n"); g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE, delay, message_handler, NULL, NULL); } //g_print ("message_complete->exit\n"); }
static MasterTimeout * master_timeout_new (FlowSshMasterRegistry *ssh_master_registry, FlowSshMaster *ssh_master) { MasterTimeout *master_timeout = g_slice_new (MasterTimeout); master_timeout->registry = ssh_master_registry; master_timeout->master = ssh_master; master_timeout->timeout_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, 30, (GSourceFunc) master_timeout_timed_out_cb, master_timeout, NULL); return master_timeout; }
uint MiracBroker::CreateTimer(int seconds) { TimerCallbackData* data = new TimerCallbackData(this); uint timer_id = g_timeout_add_seconds_full( G_PRIORITY_DEFAULT, seconds, on_timeout, data, on_timeout_remove); if (timer_id > 0) { data->timer_id_ = timer_id; timers_.push_back(timer_id); } else { delete data; } return timer_id; }
static void mgmt_user_confirm_request(int sk, uint16_t index, void *buf, size_t len) { struct mgmt_ev_user_confirm_request *ev = buf; struct controller_info *info; char addr[18]; int err; if (len < sizeof(*ev)) { error("Too small user_confirm_request event"); return; } ba2str(&ev->bdaddr, addr); DBG("hci%u %s confirm_hint %u", index, addr, ev->confirm_hint); if (index > max_index) { error("Unexpected index %u in user_confirm_request event", index); return; } if (ev->confirm_hint) { struct confirm_data *data; data = g_new0(struct confirm_data, 1); data->index = index; bacpy(&data->bdaddr, &ev->bdaddr); g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, 1, confirm_accept, data, g_free); return; } info = &controllers[index]; err = btd_event_user_confirm(&info->bdaddr, &ev->bdaddr, btohl(ev->value)); if (err < 0) { error("btd_event_user_confirm: %s", strerror(-err)); mgmt_confirm_reply(index, &ev->bdaddr, FALSE); } }
static JSBool gjs_timeout_add_seconds(JSContext *context, JSObject *obj, uintN argc, jsval *argv, jsval *retval) { GClosure *closure; JSObject *callback; guint32 interval; guint id; /* See comment for timeout_add above */ if (!gjs_parse_args(context, "timeout_add_seconds", "uo", argc, argv, "interval", &interval, "callback", &callback)) return JS_FALSE; closure = gjs_closure_new(context, callback, "timeout_seconds"); if (closure == NULL) return JS_FALSE; g_closure_ref(closure); g_closure_sink(closure); id = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, interval, closure_source_func, closure, closure_destroy_notify); /* this is needed to remove the timeout if the JSContext is * destroyed. */ g_closure_add_invalidate_notifier(closure, GUINT_TO_POINTER(id), closure_invalidated); if (!JS_NewNumberValue(context, id, retval)) return JS_FALSE; return JS_TRUE; }
/** * gdk_threads_add_timeout_seconds_full: (rename-to gdk_threads_add_timeout_seconds) * @priority: the priority of the timeout source. Typically this will be in the * range between #G_PRIORITY_DEFAULT_IDLE and #G_PRIORITY_HIGH_IDLE. * @interval: the time between calls to the function, in seconds * @function: function to call * @data: data to pass to @function * @notify: (allow-none): function to call when the timeout is removed, or %NULL * * A variant of gdk_threads_add_timeout_full() with second-granularity. * See g_timeout_add_seconds_full() for a discussion of why it is * a good idea to use this function if you don’t need finer granularity. * * Returns: the ID (greater than 0) of the event source. * * Since: 2.14 */ guint gdk_threads_add_timeout_seconds_full (gint priority, guint interval, GSourceFunc function, gpointer data, GDestroyNotify notify) { GdkThreadsDispatch *dispatch; g_return_val_if_fail (function != NULL, 0); dispatch = g_slice_new (GdkThreadsDispatch); dispatch->func = function; dispatch->data = data; dispatch->destroy = notify; return g_timeout_add_seconds_full (priority, interval, gdk_threads_dispatch, dispatch, gdk_threads_dispatch_free); }
static void get_url (GrlNetWc *self, const char *url, GHashTable *headers, GAsyncResult *result, GCancellable *cancellable) { guint id; GTimeVal now; struct request_clos *c; GrlNetWcPrivate *priv = self->priv; /* closure */ c = g_new (struct request_clos, 1); c->self = self; c->url = g_strdup (url); c->headers = headers? g_hash_table_ref (headers): NULL; c->result = result; c->cancellable = cancellable; g_get_current_time (&now); if ((now.tv_sec - priv->last_request.tv_sec) > priv->throttling || is_mocked()) { id = g_idle_add_full (G_PRIORITY_HIGH_IDLE, get_url_cb, c, request_clos_destroy); } else { GRL_DEBUG ("delaying web request"); priv->last_request.tv_sec += priv->throttling; id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, priv->last_request.tv_sec - now.tv_sec, get_url_cb, c, request_clos_destroy); } c->source_id = id; g_queue_push_head (self->priv->pending, c); }
guint aqualung_timeout_add(guint interval, GSourceFunc function, gpointer data) { threads_dispatch_t * dispatch; dispatch = g_slice_new(threads_dispatch_t); dispatch->func = function; dispatch->data = data; dispatch->destroy = NULL; if (interval % 1000 == 0) { return g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, interval / 1000, threads_dispatch, dispatch, threads_dispatch_free); } return g_timeout_add_full(G_PRIORITY_DEFAULT, interval, threads_dispatch, dispatch, threads_dispatch_free); }
void MediaSet::keepAlive (const KmsMediaObjectRef &mediaObject) throw (KmsMediaServerException) { std::shared_ptr<MediaObjectImpl> mo; std::shared_ptr<AutoReleaseData> data; std::map<KmsMediaObjectId, std::shared_ptr<AutoReleaseData>>::iterator it; if (!canBeAutoreleased (mediaObject) ) { GST_DEBUG ("MediaObject %" G_GINT64_FORMAT " is not auto releasable", mediaObject.id); return; } /* Check that object exists and it is not exluded from GC */ mo = getMediaObject<MediaObjectImpl> (mediaObject); if (mo->getExcludeFromGC () ) { GST_DEBUG ("MediaObject %" G_GINT64_FORMAT " is excluded from GC", mediaObject.id); return; } mutex.lock(); it = mediaObjectsAlive.find (mediaObject.id); if (it != mediaObjectsAlive.end() ) { data = it->second; if (data->timeoutId != 0) g_source_remove (data->timeoutId); } data->timeoutId = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, mo->getGarbageCollectorPeriod() * 2, auto_release, (gpointer) data.get (), NULL); mutex.unlock(); }