/* * Close the notification that has id. * * reasons: * -1 -> notification is a replacement, no NotificationClosed signal emitted * 1 -> the notification expired * 2 -> the notification was dismissed by the user_data * 3 -> The notification was closed by a call to CloseNotification */ int notification_close_by_id(int id, int reason) { notification *target = NULL; for (GList * iter = g_queue_peek_head_link(displayed); iter; iter = iter->next) { notification *n = iter->data; if (n->id == id) { g_queue_remove(displayed, n); g_queue_push_tail(history, n); target = n; break; } } for (GList * iter = g_queue_peek_head_link(queue); iter; iter = iter->next) { notification *n = iter->data; if (n->id == id) { g_queue_remove(queue, n); g_queue_push_tail(history, n); target = n; break; } } if (reason > 0 && reason < 4 && target != NULL) { notificationClosed(target, reason); } wake_up(); return reason; }
TEST_F(GQueueTest, remove) { int testData1 = 42; int testData2 = 1337; int testData3 = 26; GList *list = NULL; list = g_list_append(list, &testData1); list = g_list_append(list, &testData2); queue->head = list; queue->tail = g_list_last(list); queue->length = 2; gboolean removed = g_queue_remove(queue, &testData3); ASSERT_FALSE(removed) << "removal of unknown element should not succeed"; ASSERT_EQ(2, queue->length) << "queue length should still be two after failing to remove"; ASSERT_NE(queue->head, queue->tail) << "queue tail should not be equal to head after failing to remove"; removed = g_queue_remove(queue, &testData2); ASSERT_TRUE(removed) << "removal of second element should succeed"; ASSERT_TRUE(queue->head != NULL) << "queue head should not be NULL after removing second element"; ASSERT_EQ(queue->head, queue->tail) << "queue head should be equal to tail after removing second element"; ASSERT_EQ(&testData1, queue->head->data) << "first queue element data should be set"; ASSERT_TRUE(queue->head->prev == NULL) << "first queue element should not have a previous element"; ASSERT_TRUE(queue->head->next == NULL) << "first queue element should not have a next element"; ASSERT_EQ(1, queue->length) << "queue length should be one after removing an element"; removed = g_queue_remove(queue, &testData1); ASSERT_TRUE(removed) << "removal of first element should succeed"; ASSERT_TRUE(queue->head == NULL) << "queue head should be NULL after removing first element"; ASSERT_TRUE(queue->tail == NULL) << "queue tail should be NULL after removing first element"; ASSERT_EQ(0, queue->length) << "queue length should be zero after removing another element"; }
void account_list_remove(const gchar *accountID) { account_t *target = account_list_get_by_id(accountID); if (target) { #if GLIB_CHECK_VERSION(2, 30, 0) if (!g_queue_remove(accountQueue, target)) ERROR("Could not remove account with ID %s", accountID); #else g_queue_remove(accountQueue, target); #endif } }
// remove gates with no neighbors (singletons) // void gates_remove_singletons (GQueue *gates) { gboolean done = FALSE; gate_t *g; while (!done) { done = TRUE; g = NULL; for (GList *iter=g_queue_peek_head_link (gates);iter;iter=g_list_next(iter)) { g = (gate_t*)iter->data; if (g->ng==0) { done = FALSE; // sanity check (no gate should have this one as a neighbor) for (GList *iter2=g_queue_peek_head_link (gates);iter2;iter2=g_list_next(iter2)) { gate_t *g2 = (gate_t*)iter2->data; assert (!gate_is_neighbor (g2, g)); } printf ("removing gate %d %d\n", g->uid, rand()); g_queue_remove (gates, g); break; } } } }
static ModemCall * modem_call_service_get_dialed (ModemCallService *self, char const *object_path, char const *remote) { ModemCallServicePrivate *priv = self->priv; ModemCall *ci; ci = g_hash_table_lookup (priv->instances, object_path); if (ci) { DEBUG ("call already exists %p", (void *)ci); if (g_queue_find (priv->dialing.created, ci)) g_queue_remove (priv->dialing.created, ci); return ci; } ci = g_object_new (MODEM_TYPE_CALL, "object-path", object_path, "call-service", self, "remote", remote, "state", MODEM_CALL_STATE_DIALING, "ofono-state", "dialing", "terminating", FALSE, "originating", TRUE, NULL); modem_call_service_connect_to_instance (self, ci); return ci; }
static void empathy_mic_menu_microphone_removed_cb (EmpathyMicMonitor *monitor, guint source_idx, EmpathyMicMenu *self) { EmpathyMicMenuPrivate *priv = self->priv; GList *l; for (l = priv->microphones->head; l != NULL; l = l->next) { GtkRadioAction *action = l->data; gint value; g_object_get (action, "value", &value, NULL); if (value != (gint) source_idx) { action = NULL; continue; } g_signal_handlers_disconnect_by_func (action, G_CALLBACK (empathy_mic_menu_activate_cb), self); gtk_action_group_remove_action (priv->action_group, GTK_ACTION (action)); g_queue_remove (priv->microphones, action); break; } empathy_mic_menu_update (self); }
static void on_engine_package_scan_end (SymbolDBEngine *dbe, gint process_id, gpointer user_data) { SymbolDBSystem *sdbs; SymbolDBSystemPriv *priv; EngineScanData *es_data; es_data = (EngineScanData *)user_data; sdbs = es_data->sdbs; priv = sdbs->priv; /* first of all disconnect the signals */ g_signal_handlers_disconnect_by_func (dbe, on_engine_package_scan_end, user_data); DEBUG_PRINT ("emitting scan_package_end"); /* notify listeners that we ended the scan of the package */ g_signal_emit (sdbs, signals[SCAN_PACKAGE_END], 0, es_data->package_name); /* remove the data from the queue */ DEBUG_PRINT ("removing %s", es_data->package_name); g_queue_remove (priv->engine_queue, es_data); destroy_engine_scan_data (es_data); /* have we got something left in the queue? */ if (g_queue_get_length (priv->engine_queue) > 0) { /* peek the head */ es_data = g_queue_peek_head (priv->engine_queue); DEBUG_PRINT ("adding %s", es_data->package_name); sdb_system_do_engine_scan (sdbs, es_data); } }
gboolean g_attrib_cancel(GAttrib *attrib, guint id) { GList *l = NULL; struct command *cmd; GQueue *queue; if (attrib == NULL) return FALSE; queue = attrib->requests; if (queue) l = g_queue_find_custom(queue, GUINT_TO_POINTER(id), command_cmp_by_id); if (l == NULL) { queue = attrib->responses; if (!queue) return FALSE; l = g_queue_find_custom(queue, GUINT_TO_POINTER(id), command_cmp_by_id); } if (l == NULL) return FALSE; cmd = l->data; if (cmd == g_queue_peek_head(queue) && cmd->sent) cmd->func = NULL; else { g_queue_remove(queue, cmd); command_destroy(cmd); } return TRUE; }
void mbb_session_del_var(struct mbb_var *var) { mbb_plock_writer_lock(); g_queue_remove(&var_queue, var); if (ht != NULL) { struct mbb_session_var *priv; struct mbb_session *ss; GHashTableIter iter; priv = mbb_var_get_priv(var); g_hash_table_iter_init(&iter, ht); while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &ss)) { gpointer data; if (session_lookup_var(ss, var, &data)) { if (priv->op_free != NULL) priv->op_free(data); g_hash_table_remove(ss->vars, var); } } } mbb_plock_writer_unlock(); }
void XournalScheduler::removeAllJobs() { XOJ_CHECK_TYPE(XournalScheduler); g_mutex_lock(&this->jobQueueMutex); for (int priority = JOB_PRIORITY_URGENT; priority < JOB_N_PRIORITIES; priority++) { int length = g_queue_get_length(this->jobQueue[priority]); for (int i = 0; i < length; i++) { Job* job = (Job*) g_queue_peek_nth(this->jobQueue[priority], i); JobType type = job->getType(); if (type == JOB_TYPE_PREVIEW || type == JOB_TYPE_RENDER) { job->deleteJob(); g_queue_remove(this->jobQueue[priority], job); job->unref(); } } } g_mutex_unlock(&this->jobQueueMutex); }
void XournalScheduler::removeSource(void* source, JobType type, JobPriority priority) { XOJ_CHECK_TYPE(XournalScheduler); g_mutex_lock(&this->jobQueueMutex); int length = g_queue_get_length(this->jobQueue[priority]); for (int i = 0; i < length; i++) { Job* job = (Job*) g_queue_peek_nth(this->jobQueue[priority], i); if (job->getType() == type) { if (job->getSource() == source) { job->deleteJob(); g_queue_remove(this->jobQueue[priority], job); job->unref(); break; } } } // wait until the last job is done // we can be sure we don't access "source" finishTask(); g_mutex_unlock(&this->jobQueueMutex); }
int partlist_delete_custom(joblist *jlist, Job *job, int njobs) { int i, val = 0; partlist *p = (partlist *)NULL; if (jlist[job->job].part == (partlist *) NULL) { fprintf(stderr, "Error deleting a job that is not assigned\n"); val = 1; goto CLEAN; } p = (jlist + job->job)->part; if (g_queue_remove(p->list, job)) { jlist[job->job].part = (partlist *)NULL; p->totcompweight -= job->weight * p->sumtimes[job->job] + job->processingime * p->sumweights[job->job]; p->completiontime -= job->processingime; for (i = job->job; i < njobs; ++i) { p->sumtimes[i] -= job->processingime; } for (i = 0; i < job->job; ++i) { p->sumweights[i] -= job->weight; } } else { printf("We didn't find the job\n"); } CLEAN: return val; }
/** * clutter_event_remove_source: * @actor: A #ClutterActor. * * Removes and frees all events in the queue that contain a source that * is the given clutter actor. */ void clutter_event_remove_source (ClutterActor *actor) { ClutterMainContext *context = clutter_context_get_default (); GList *l; if (!context->events_queue) return; l = context->events_queue->head; while (l) { GList *nextl = l->next; ClutterEvent *event = (ClutterEvent*)l->data; /* if this event's source is this actor, remove it from the queue */ if (event->any.source == actor) { g_queue_remove(context->events_queue, l->data); clutter_event_free(event); } /* We're safe to carry on here because we saved our last * 'next' pointer before removing this one */ l = nextl; } }
bool netlink_cancel(struct netlink_info *netlink, unsigned int id) { struct command *command; if (!netlink || id == 0) return false; if (!netlink->command_queue || !netlink->command_pending || !netlink->command_lookup) return false; command = g_hash_table_lookup(netlink->command_lookup, GUINT_TO_POINTER(id)); if (!command) return false; g_hash_table_remove(netlink->command_lookup, GUINT_TO_POINTER(id)); if (!g_queue_remove(netlink->command_queue, command)) { g_hash_table_remove(netlink->command_pending, GUINT_TO_POINTER(command->seq)); } destroy_command(command); return true; }
void rut_graphable_remove_child (RutObject *child) { RutGraphableProps *child_props = rut_object_get_properties (child, RUT_INTERFACE_ID_GRAPHABLE); RutObject *parent = child_props->parent; RutGraphableVTable *parent_vtable; RutGraphableProps *parent_props; if (!parent) return; parent_vtable = rut_object_get_vtable (parent, RUT_INTERFACE_ID_GRAPHABLE); parent_props = rut_object_get_properties (parent, RUT_INTERFACE_ID_GRAPHABLE); /* Note: we set ->parent to NULL here to avoid re-entrancy so * ->child_removed can be a general function for removing a child * that might itself call rut_graphable_remove_child() */ child_props->parent = NULL; if (parent_vtable->child_removed) parent_vtable->child_removed (parent, child); g_queue_remove (&parent_props->children, child); rut_refable_release (child, parent); }
void gsignond_plugin_proxy_cancel ( GSignondPluginProxy *self, GSignondAuthSession *session) { g_assert (GSIGNOND_IS_PLUGIN_PROXY (self)); g_assert (GSIGNOND_IS_AUTH_SESSION (session)); GSignondPluginProxyPrivate *priv = self->priv; /* cancel active session */ if (session == priv->active_session) { gsignond_plugin_cancel (priv->plugin); } else { /* cancel by de-queue */ GSignondProcessData* data = gsignond_plugin_proxy_find_by_session_iface (self, session); if (!data) { GError* error = g_error_new (GSIGNOND_ERROR, GSIGNOND_ERROR_WRONG_STATE, "Canceling an unknown session"); gsignond_auth_session_notify_process_error (session, error, NULL); g_error_free (error); return; } g_queue_remove (priv->session_queue, data); gsignond_process_data_free (data); } }
void remove_job_from_queue(Job *job) { GQueue *queue = g_hash_table_lookup(g_jobqueue, job->func); g_queue_remove(queue, job); if (g_queue_is_empty(queue)) { g_hash_table_remove(g_jobqueue, job->func); } }
void purple_notify_user_info_remove_entry(PurpleNotifyUserInfo *user_info, PurpleNotifyUserInfoEntry *entry) { g_return_if_fail(user_info != NULL); g_return_if_fail(entry != NULL); g_queue_remove(&user_info->entries, entry); }
static void destroy_lookup(struct resolv_lookup *lookup) { if (lookup->ipv4_query != NULL) { g_queue_remove(lookup->resolv->query_queue, lookup->ipv4_query); destroy_query(lookup->ipv4_query); } if (lookup->ipv6_query != NULL) { g_queue_remove(lookup->resolv->query_queue, lookup->ipv6_query); destroy_query(lookup->ipv6_query); } g_free(lookup->results); g_free(lookup); }
/** * g_async_queue_remove_unlocked: * @queue: a #GAsyncQueue * @data: the @data to remove from the @queue * * Remove an item from the queue. This function does not block. * * This function must be called while holding the @queue's lock. * * Returns: %TRUE if the item was removed * * Since: 2.46 */ gboolean g_async_queue_remove_unlocked (GAsyncQueue *queue, gpointer data) { g_return_val_if_fail (queue != NULL, FALSE); g_return_val_if_fail (data != NULL, FALSE); return g_queue_remove (&queue->queue, data); }
/** * gst_flow_combiner_remove_pad: * @combiner: the #GstFlowCombiner * @pad: (transfer none): the #GstPad to remove * * Removes a #GstPad from the #GstFlowCombiner. * * Since: 1.4 */ void gst_flow_combiner_remove_pad (GstFlowCombiner * combiner, GstPad * pad) { g_return_if_fail (combiner != NULL); g_return_if_fail (pad != NULL); if (g_queue_remove (&combiner->pads, pad)) gst_object_unref (pad); }
/* * Close the notification that has id. * * reasons: * -1 -> notification is a replacement, no NotificationClosed signal emitted * 1 -> the notification expired * 2 -> the notification was dismissed by the user_data * 3 -> The notification was closed by a call to CloseNotification */ int notification_close_by_id(int id, int reason) { int free = 0; notification *target = NULL; for (GList * iter = g_queue_peek_head_link(displayed); iter; iter = iter->next) { notification *n = iter->data; if (n->id == id) { g_queue_remove(displayed, n); if(reason != 4) { history_push(n); } else free =1 ; target = n; break; } } for (GList * iter = g_queue_peek_head_link(queue); iter; iter = iter->next) { notification *n = iter->data; if (n->id == id) { g_queue_remove(queue, n); if(reason != 4) { history_push(n); } else free =1 ; target = n; break; } } if (reason > 0 && reason < 5 && target != NULL) { notificationClosed(target, reason); } if(free) { notification_free(target); } wake_up(); return reason; }
int closeSocket(int socket, session_t* session) { close(socket); FD_CLR(socket, &session->read_fds); g_queue_remove(session->q, GINT_TO_POINTER(socket)); int max = session->listener; g_queue_foreach(session->q, check_max, &max); return max; }
void fb_data_remove_message(FbData *fata, FbApiMessage *msg) { FbDataPrivate *priv; g_return_if_fail(FB_IS_DATA(fata)); priv = fata->priv; g_queue_remove(priv->msgs, msg); }
/* * Called from the compare thread on the primary * for compare packet with secondary list of the * specified connection when a new packet was * queued to it. */ static void colo_compare_connection(void *opaque, void *user_data) { CompareState *s = user_data; Connection *conn = opaque; Packet *pkt = NULL; GList *result = NULL; int ret; while (!g_queue_is_empty(&conn->primary_list) && !g_queue_is_empty(&conn->secondary_list)) { pkt = g_queue_pop_head(&conn->primary_list); switch (conn->ip_proto) { case IPPROTO_TCP: result = g_queue_find_custom(&conn->secondary_list, pkt, (GCompareFunc)colo_packet_compare_tcp); break; case IPPROTO_UDP: result = g_queue_find_custom(&conn->secondary_list, pkt, (GCompareFunc)colo_packet_compare_udp); break; case IPPROTO_ICMP: result = g_queue_find_custom(&conn->secondary_list, pkt, (GCompareFunc)colo_packet_compare_icmp); break; default: result = g_queue_find_custom(&conn->secondary_list, pkt, (GCompareFunc)colo_packet_compare_other); break; } if (result) { ret = compare_chr_send(s, pkt->data, pkt->size, pkt->vnet_hdr_len); if (ret < 0) { error_report("colo_send_primary_packet failed"); } trace_colo_compare_main("packet same and release packet"); g_queue_remove(&conn->secondary_list, result->data); packet_destroy(pkt, NULL); } else { /* * If one packet arrive late, the secondary_list or * primary_list will be empty, so we can't compare it * until next comparison. */ trace_colo_compare_main("packet different"); g_queue_push_head(&conn->primary_list, pkt); /* TODO: colo_notify_checkpoint();*/ break; } } }
/** * remove the connection referenced by entry from the pool */ void network_connection_pool_remove(network_connection_pool *pool, network_connection_pool_entry *entry) { network_socket *sock = entry->sock; if (sock->response == NULL) { g_critical("%s: (remove) remove socket from pool, response is NULL, src is %s, dst is %s", G_STRLOC, sock->src->name->str, sock->dst->name->str); } network_connection_pool_entry_free(entry, TRUE); g_queue_remove(pool, entry); }
static void ml_api_defer_free(pa_defer_event *e) { trace_info("F %s\n", __func__); pa_mainloop *ml = e->mainloop; g_queue_remove(ml->queue, e); g_slice_free(pa_defer_event, e); pa_mainloop_wakeup(ml); }
static void update_mru_docs_head(GeanyDocument *doc) { if (doc) { g_queue_remove(mru_docs, doc); g_queue_push_head(mru_docs, doc); if (g_queue_get_length(mru_docs) > MAX_MRU_DOCS) g_queue_pop_tail(mru_docs); } }
static void destroy_lookup(struct resolv_lookup *lookup) { debug(lookup->resolv, "lookup %p id %d ipv4 %p ipv6 %p", lookup, lookup->id, lookup->ipv4_query, lookup->ipv6_query); if (lookup->ipv4_query != NULL) { g_queue_remove(lookup->resolv->query_queue, lookup->ipv4_query); destroy_query(lookup->ipv4_query); } if (lookup->ipv6_query != NULL) { g_queue_remove(lookup->resolv->query_queue, lookup->ipv6_query); destroy_query(lookup->ipv6_query); } g_free(lookup->results); g_free(lookup); }
static void _foreach_new_active(struct CallActiveViewData *win, int id) { if (id != win->parent.id) { call_common_window_to_pending(win); } else { call_common_window_to_active(win); g_queue_remove(active_calls_list, win); g_queue_push_head(active_calls_list, win); } }