Ejemplo n.º 1
0
/**
 * Free the members of the struct result_queue.
 * The memory usedy by result_queue will be freed
 * automatically, since it's a GSource
 * This function is called when there are no
 * more reference to the queue, before
 * the source is freed.
 * @param source the source to free
 */
static void result_queue_source_finalize(GSource *source)
{
        struct result_queue *queue;
        GAsyncQueue* async_queue;
        struct event *ev;

        g_return_if_fail(source);
        queue = RESULT_QUEUE(source);
        async_queue = queue->async_queue;
        g_async_queue_lock(async_queue);

        /* Just in case: empty the queue, release the results and unreference */
        while((ev=(struct event *)g_async_queue_try_pop_unlocked(async_queue))!=NULL) {
                struct result *result = ev->result;
                if(result && result->release) {
                        result->release(result);
                }
                event_free(ev);
        }
        g_async_queue_unref_and_unlock(async_queue);
        result_queue_counter--;
}
Ejemplo n.º 2
0
/**
 * This function wrapped around the real thread function logging two
 * events when the thread starts & stops 
 *
 * @param[in] st thread state
 **/
static gpointer
z_thread_func(gpointer st)
{
  ZThread *self = (ZThread *) st;
  
  do
    {
      z_thread_func_core(self, NULL);
      self = NULL;
      g_async_queue_lock(queue);
      self = (ZThread *) g_async_queue_try_pop_unlocked(queue);
      if (!self)
        {
          num_threads--;
          g_async_queue_unref_and_unlock(queue);
        }
      else
        g_async_queue_unlock(queue);
    }
  while (self != NULL);

  return NULL;
}