Exemple #1
0
static void
nice_component_init (NiceComponent *component)
{
  g_atomic_int_inc (&n_components_created);
  nice_debug ("Created NiceComponent (%u created, %u destroyed)",
      n_components_created, n_components_destroyed);

  component->id = 0;
  component->state = NICE_COMPONENT_STATE_DISCONNECTED;
  component->restart_candidate = NULL;
  component->tcp = NULL;
  component->agent = NULL;
  component->stream = NULL;

  g_mutex_init (&component->io_mutex);
  g_queue_init (&component->pending_io_messages);
  component->io_callback_id = 0;

  component->own_ctx = g_main_context_new ();
  component->stop_cancellable = g_cancellable_new ();
  component->stop_cancellable_source =
      g_cancellable_source_new (component->stop_cancellable);
  g_source_set_dummy_callback (component->stop_cancellable_source);
  g_source_attach (component->stop_cancellable_source, component->own_ctx);
  component->ctx = g_main_context_ref (component->own_ctx);

  /* Start off with a fresh main context and all I/O paused. This
   * will be updated when nice_agent_attach_recv() or nice_agent_recv_messages()
   * are called. */
  nice_component_set_io_context (component, NULL);
  nice_component_set_io_callback (component, NULL, NULL, NULL, 0, NULL);

  g_queue_init (&component->queued_tcp_packets);
}
Exemple #2
0
/**
 * THE GIVEN INPUT TRIANGLES MUST BE GIVEN WITH AN EXTRA REFERENCE SINCE
 * THEY WILL BE UNREFFED!
 */
static void
p2tr_cdt_flip_fix (P2trCDT *self,
                   GList   *initial_triangles)
{
    GQueue flipped_edges, tris_to_fix;
    GList *iter;

    g_queue_init (&flipped_edges);
    g_queue_init (&tris_to_fix);

    for (iter = initial_triangles; iter != NULL; iter = iter->next)
        g_queue_push_tail (&tris_to_fix, iter->data);

    while (! g_queue_is_empty (&tris_to_fix))
    {
        P2trTriangle *tri = (P2trTriangle*)g_queue_pop_head (&tris_to_fix);
        P2trCircle   circum_circle;
        gint         i;

        if (p2tr_triangle_is_removed (tri))
        {
            p2tr_triangle_unref (tri);
            continue;
        }

        p2tr_triangle_get_circum_circle (tri, &circum_circle);

        for (i = 0; i < 3; i++)
        {
            P2trEdge  *e = tri->edges[i];
            P2trPoint *opposite;

            if (e->constrained || e->delaunay)
                continue;

            opposite = p2tr_triangle_get_opposite_point (e->mirror->tri, e->mirror);
            if (! p2tr_circle_test_point_outside(&circum_circle, &opposite->c))
            {
                P2trEdge *flipped;
                if (p2tr_cdt_try_flip (self, e, &tris_to_fix, &flipped))
                {
                    g_queue_push_tail (&flipped_edges, flipped);
                    /* Stop iterating this triangle since it doesn't exist
                     * any more */
                    break;
                }
            }
        }

        /* We are finished with the triangle, so unref it as promised */
        p2tr_triangle_unref (tri);
    }

    while (! g_queue_is_empty (&flipped_edges))
    {
        P2trEdge *e = (P2trEdge*) g_queue_pop_head (&flipped_edges);
        e->delaunay = e->mirror->delaunay = FALSE;
        p2tr_edge_unref (e);
    }
}
Exemple #3
0
void li_event_loop_init(liEventLoop *loop, struct ev_loop *evloop) {
	ev_ref(evloop);
	loop->end = 0;
	loop->loop = evloop;
	g_queue_init(&loop->watchers);
	g_queue_init(&loop->closing_sockets);
	li_job_queue_init(&loop->jobqueue, loop);
}
Exemple #4
0
static void
hrt_task_runner_init(HrtTaskRunner *runner)
{
    /* Most stuff is in the constructor so the event loop type
     * will have been set.
     */

    g_queue_init(&runner->completed_tasks);
    g_queue_init(&runner->unlocked_completed_tasks);
    runner->completed_tasks_lock = g_mutex_new();
}
static void
gst_hls_sink2_init (GstHlsSink2 * sink)
{
  GstElement *mux;

  sink->location = g_strdup (DEFAULT_LOCATION);
  sink->playlist_location = g_strdup (DEFAULT_PLAYLIST_LOCATION);
  sink->playlist_root = g_strdup (DEFAULT_PLAYLIST_ROOT);
  sink->playlist_length = DEFAULT_PLAYLIST_LENGTH;
  sink->max_files = DEFAULT_MAX_FILES;
  sink->target_duration = DEFAULT_TARGET_DURATION;
  g_queue_init (&sink->old_locations);

  sink->splitmuxsink = gst_element_factory_make ("splitmuxsink", NULL);
  gst_bin_add (GST_BIN (sink), sink->splitmuxsink);

  mux = gst_element_factory_make ("mpegtsmux", NULL);
  g_object_set (sink->splitmuxsink, "location", sink->location, "max-size-time",
      ((GstClockTime) sink->target_duration * GST_SECOND),
      "send-keyframe-requests", TRUE, "muxer", mux, "reset-muxer", FALSE, NULL);

  GST_OBJECT_FLAG_SET (sink, GST_ELEMENT_FLAG_SINK);

  gst_hls_sink2_reset (sink);
}
static void
modem_call_service_init (ModemCallService *self)
{
  DEBUG ("enter");

  self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self,
      MODEM_TYPE_CALL_SERVICE, ModemCallServicePrivate);

  g_queue_init (self->priv->dialing.queue);
  g_queue_init (self->priv->dialing.created);

  self->priv->instances = g_hash_table_new_full (
      g_str_hash, g_str_equal, NULL, g_object_unref);

  self->priv->forwarded = NULL;
}
Exemple #7
0
RmTreeMerger *rm_tm_new(RmSession *session) {
    RmTreeMerger *self = g_slice_new(RmTreeMerger);
    self->session = session;
    g_queue_init(&self->valid_dirs);

    self->result_table = g_hash_table_new_full((GHashFunc)rm_directory_hash,
                                               (GEqualFunc)rm_directory_equal, NULL,
                                               (GDestroyNotify)g_queue_free);

    self->file_groups =
        g_hash_table_new_full((GHashFunc)rm_digest_hash, (GEqualFunc)rm_digest_equal,
                              NULL, (GDestroyNotify)g_queue_free);

    self->file_checks = g_hash_table_new_full((GHashFunc)rm_digest_hash,
                                              (GEqualFunc)rm_digest_equal, NULL, NULL);

    self->known_hashs = g_hash_table_new_full(NULL, NULL, NULL, NULL);

    rm_trie_init(&self->dir_tree);
    rm_trie_init(&self->count_tree);

    rm_tm_chunk_paths(self, session->cfg->paths);

    return self;
}
static void
gcr_importer_init (GcrImporter *self)
{
	self->pv = G_TYPE_INSTANCE_GET_PRIVATE (self, GCR_TYPE_IMPORTER, GcrImporterPrivate);
	self->pv->behavior = GCR_IMPORTER_PROMPT_NEEDED;
	g_queue_init (&self->pv->queue);
}
Exemple #9
0
int main()
{
	GTimer *timer = g_timer_new();
	g_timer_start(timer);
	GQueue *queue = g_queue_new();
	g_queue_init(queue);
	int i;
	char *element;
	for(i=0;i<100;i++)
	{
		element = (char*)g_malloc(128);
		sprintf(element,"element_%d",i);
		g_queue_push_tail(queue,element);
	}	
	printf("%s\n",(char*)g_queue_pop_head(queue));	
	printf("%s\n",(char*)g_queue_pop_head(queue));	
	printf("%s\n",(char*)g_queue_pop_head(queue));	
	printf("%s\n",(char*)g_queue_pop_head(queue));
	g_queue_free(queue);
	g_timer_stop(timer);

	gulong *mincro;
	printf("%f\n",g_timer_elapsed(timer,mincro));
		
}
Exemple #10
0
static gboolean
complete_tasks_in_runner_thread(void *data)
{
    HrtTaskRunner *runner = HRT_TASK_RUNNER(data);
    HrtTask *task;

    g_mutex_lock(runner->completed_tasks_lock);

    /* unlocked_completed_tasks must be empty because we only run one
     * of these idles at a time, and at the end of the idle we
     * always empty unlocked_completed_tasks if the app did not.
     */
    g_assert(g_queue_get_length(&runner->unlocked_completed_tasks) == 0);

    /* just copy entire GQueue by value */
    runner->unlocked_completed_tasks = runner->completed_tasks;
    g_queue_init(&runner->completed_tasks);

    runner->completed_tasks_idle_id = 0;

    g_mutex_unlock(runner->completed_tasks_lock);

    /* During this emission, unlocked_completed_tasks MUST be drained or
     * else we'll just drop its contents on the floor.
     */
    g_signal_emit(G_OBJECT(runner), signals[TASKS_COMPLETED], 0);

    /* drop any tasks that weren't taken by the app on the floor */
    while ((task = hrt_task_runner_pop_completed(runner)) != NULL) {
        g_object_unref(task);
    }

    return FALSE;
}
Exemple #11
0
static HrtInvoker*
hrt_invoker_new(HrtTask    *task,
                HrtWatcher *first_watcher)
{
    HrtInvoker *invoker;

    invoker = g_slice_new(HrtInvoker);

    invoker->refcount = 1;
    invoker->task = task;
    g_object_ref(task);

    invoker->pending_watchers_lock = g_mutex_new();
    g_queue_init(&invoker->pending_watchers);

    /* passing in first_watcher lets us avoid locking the queue for
     * just one watcher which is probably the most common case.
     * Using GStaticMutex we could even potentially
     * avoid creating a mutex, but for now skipping that.
     */
    _hrt_watcher_ref(first_watcher);
    g_queue_push_tail(&invoker->pending_watchers, first_watcher);

    return invoker;
}
Exemple #12
0
FmList *fm_list_new (FmListFuncs *funcs)
{
    FmList *list = g_slice_new (FmList);
    list->funcs = funcs;
    g_queue_init (&list->list);
    list->n_ref = 1;
    return list;
}
static void
gst_validate_monitor_init (GstValidateMonitor * monitor)
{
  g_mutex_init (&monitor->mutex);

  g_mutex_init (&monitor->overrides_mutex);
  g_queue_init (&monitor->overrides);
}
Exemple #14
0
static GstTraceValues *
make_trace_values (GstClockTime window)
{
  GstTraceValues *self = g_slice_new0 (GstTraceValues);
  self->window = window;
  g_queue_init (&self->values);
  return self;
}
static void
tp_yts_client_init (TpYtsClient *self)
{
  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TP_TYPE_YTS_CLIENT,
      TpYtsClientPrivate);

  g_queue_init (&self->priv->incoming_channels);
}
Exemple #16
0
/**
 * g_queue_clear:
 * @queue: a #GQueue
 *
 * Removes all the elements in @queue. If queue elements contain
 * dynamically-allocated memory, they should be freed first.
 *
 * Since: 2.14
 */
void
g_queue_clear (GQueue *queue)
{
  g_return_if_fail (queue != NULL);

  g_list_free (queue->head);
  g_queue_init (queue);
}
Exemple #17
0
void li_chunkqueue_reset(liChunkQueue *cq) {
	if (!cq) return;
	cq->is_closed = FALSE;
	cq->bytes_in = cq->bytes_out = cq->length = 0;
	g_queue_foreach(&cq->queue, __chunk_free, cq);
	assert(cq->mem_usage == 0);
	cq->mem_usage = 0;
	g_queue_init(&cq->queue); /* should be empty now */
}
Exemple #18
0
void li_job_queue_init(liJobQueue* jq, liEventLoop *loop) {
	li_event_prepare_init(loop, &jq->prepare_watcher, job_queue_prepare_cb);
	li_event_async_init(loop, &jq->async_queue_watcher, job_async_queue_cb);
	li_event_timer_init(loop, &jq->queue_watcher, job_queue_watcher_cb);

	/* job queue */
	g_queue_init(&jq->queue);
	jq->async_queue = g_async_queue_new();
}
Exemple #19
0
static void attrs_init(struct sdp_attributes *a) {
	g_queue_init(&a->list);
	/* a->name_hash = g_hash_table_new(str_hash, str_equal); */
	a->id_hash = g_hash_table_new(g_int_hash, g_int_equal);
	/* a->name_lists_hash = g_hash_table_new_full(str_hash, str_equal,
			NULL, (GDestroyNotify) g_queue_free); */
	a->id_lists_hash = g_hash_table_new_full(g_int_hash, g_int_equal,
			NULL, (GDestroyNotify) g_queue_free);
}
void detalgo_init(){

	/* Initialize random number generator. */
	gsl_rng_env_setup();
	T = gsl_rng_default;
	rng = gsl_rng_alloc(T);

	/* Create queues. */
	queues[FLOW_1][GOOD] = g_queue_new();
	queues[FLOW_1][BAD] = g_queue_new();
	queues[FLOW_2][GOOD] = g_queue_new();
	queues[FLOW_2][BAD] = g_queue_new();

	/* Initialize queues. */
	g_queue_init(queues[FLOW_1][GOOD]);
	g_queue_init(queues[FLOW_1][BAD]);
	g_queue_init(queues[FLOW_2][GOOD]);
	g_queue_init(queues[FLOW_2][BAD]);
}
static void
gst_validate_monitor_init (GstValidateMonitor * monitor)
{
  g_mutex_init (&monitor->mutex);

  g_mutex_init (&monitor->overrides_mutex);
  g_queue_init (&monitor->overrides);

  monitor->verbosity = GST_VALIDATE_VERBOSITY_POSITION;
}
Exemple #22
0
goffset li_chunkqueue_skip_all(liChunkQueue *cq) {
	goffset bytes = cq->length;

	g_queue_foreach(&cq->queue, __chunk_free, cq);
	g_queue_init(&cq->queue);

	cq->bytes_out += bytes;
	cq->length = 0;

	return bytes;
}
int init_virtual_switch_drv(void)
{
	g_queue_init(&gl_ctx.queue);
	g_mutex_init(&gl_ctx.mutex);

	pthread_t thread_id;
	if (pthread_create(&thread_id, NULL, (thread_entry_func)_monitor_thread, NULL))
		return -1;

	return register_dev_drv(&virtual_switch_drv);
}
Exemple #24
0
PurpleNotifyUserInfo *
purple_notify_user_info_new()
{
	PurpleNotifyUserInfo *user_info;

	user_info = g_new0(PurpleNotifyUserInfo, 1);
	PURPLE_DBUS_REGISTER_POINTER(user_info, PurpleNotifyUserInfo);
	g_queue_init(&user_info->entries);

	return user_info;
}
static gboolean
gst_vaapi_encoder_mpeg2_init (GstVaapiEncoder * base_encoder)
{
  GstVaapiEncoderMpeg2 *const encoder =
      GST_VAAPI_ENCODER_MPEG2_CAST (base_encoder);

  /* re-ordering */
  g_queue_init (&encoder->b_frames);

  return TRUE;
}
Exemple #26
0
static RmDirectory *rm_directory_new(char *dirname) {
    RmDirectory *self = g_new0(RmDirectory, 1);

    self->file_count = 0;
    self->dupe_count = 0;
    self->prefd_files = 0;
    self->was_merged = false;
    self->was_inserted = false;
    self->mergeups = 0;

    self->dirname = dirname;
    self->finished = false;

    self->depth = 0;
    for(char *s = dirname; *s; s++) {
        self->depth += (*s == G_DIR_SEPARATOR);
    }

    RmStat dir_stat;
    if(rm_sys_stat(self->dirname, &dir_stat) == -1) {
        rm_log_perror("stat(2) failed during sort");
    } else {
        self->metadata.dir_mtime = dir_stat.st_mtime;
        self->metadata.dir_inode = dir_stat.st_ino;
        self->metadata.dir_dev = dir_stat.st_dev;
    }

    /* Special cumulative hashsum, that is not dependent on the
     * order in which the file hashes were added.
     * It is not used as full hash, but as sorting speedup.
     */
    self->digest = rm_digest_new(RM_DIGEST_CUMULATIVE, 0, 0, 0, false);

    g_queue_init(&self->known_files);
    g_queue_init(&self->children);

    self->hash_set =
        g_hash_table_new((GHashFunc)rm_digest_hash, (GEqualFunc)rm_digest_equal);

    return self;
}
Exemple #27
0
static void
hio_output_stream_init(HioOutputStream *stream)
{
    stream->fd = -1;

    stream->buffers_lock = g_mutex_new();
    g_queue_init(&stream->buffers);

    stream->write_watcher_lock = g_mutex_new();

    stream->done_notify_lock = g_mutex_new();
}
Exemple #28
0
// call->master_lock held in W
struct send_timer *send_timer_new(struct packet_stream *ps) {
	ilog(LOG_DEBUG, "creating send_timer");

	struct send_timer *st = obj_alloc0("send_timer", sizeof(*st), __send_timer_free);
	st->tt_obj.tt = &send_timer_thread;
	mutex_init(&st->lock);
	st->call = obj_get(ps->call);
	st->sink = ps;
	g_queue_init(&st->packets);

	return st;
}
Exemple #29
0
/**
 * g_async_queue_new:
 * 
 * Creates a new asynchronous queue with the initial reference count of 1.
 * 
 * Return value: the new #GAsyncQueue.
 **/
GAsyncQueue*
g_async_queue_new (void)
{
  GAsyncQueue* retval = g_new (GAsyncQueue, 1);
  retval->mutex = g_mutex_new ();
  retval->cond = NULL;
  g_queue_init (&retval->queue);
  retval->waiting_threads = 0;
  retval->ref_count = 1;
  retval->item_free_func = NULL;
  return retval;
}
Exemple #30
0
static void
modem_tones_init(ModemTones *self)
{
  self->priv = G_TYPE_INSTANCE_GET_PRIVATE(
    self, MODEM_TYPE_TONES, ModemTonesPrivate);
  self->priv->timer = g_timer_new();
  self->priv->proxy =
    dbus_g_proxy_new_for_name(dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL),
      "com.Nokia.Telephony.Tones",
      "/com/Nokia/Telephony/Tones",
      "com.Nokia.Telephony.Tones");
  g_queue_init(self->priv->stop_requests);
}