Exemplo n.º 1
0
static void
arv_stream_finalize (GObject *object)
{
	ArvStream *stream = ARV_STREAM (object);
	ArvBuffer *buffer;

	arv_debug_stream ("[Stream::finalize] Flush %d buffer[s] in input queue",
			  g_async_queue_length (stream->priv->input_queue));
	arv_debug_stream ("[Stream::finalize] Flush %d buffer[s] in output queue",
			  g_async_queue_length (stream->priv->output_queue));

	do {
		buffer = g_async_queue_try_pop (stream->priv->output_queue);
		if (buffer != NULL)
			g_object_unref (buffer);
	} while (buffer != NULL);

	do {
		buffer = g_async_queue_try_pop (stream->priv->input_queue);
		if (buffer != NULL)
			g_object_unref (buffer);
	} while (buffer != NULL);

	g_async_queue_unref (stream->priv->input_queue);
	g_async_queue_unref (stream->priv->output_queue);

	parent_class->finalize (object);
}
Exemplo n.º 2
0
static void 
mdw_dvb_demux_thread_read_write_finalize(MdwDvbDemux *self) 
{
    g_assert(self != NULL);
    MdwDvbDemuxPrivate *priv = MDW_DVB_DEMUX_GET_PRIVATE(self);
    if (priv->thread_read_write == NULL) 
    {
        return;
    } 
    DEBUG_INFO("Finalizing thread to read/write");
    g_assert(priv->main_queue != NULL);
    g_assert(priv->thread_read_write_queue != NULL);

    MdwMessage *m = mdw_message_new(MDW_MESSAGE_TYPE_FINALIZE, 0);
    mdw_message_put(m, priv->thread_read_write_queue);
    
    m = mdw_message_get(priv->main_queue, TRUE);
    g_assert(m->type == MDW_MESSAGE_TYPE_FINALIZED);
    g_assert(m->buffer == NULL);
    g_assert(m->size == 0);
    mdw_message_free(m, TRUE);

    g_assert(g_async_queue_length(priv->main_queue) == 0);
    g_assert(g_async_queue_length(priv->thread_read_write_queue) == 0);

    g_async_queue_unref(priv->main_queue);
    g_async_queue_unref(priv->thread_read_write_queue);

    priv->main_queue = NULL;
    priv->thread_read_write_queue = NULL;
    priv->thread_read_write = NULL;

}
Exemplo n.º 3
0
/* fakesink handoff callback */
static void
on_gst_buffer (GstElement * fakesink, GstBuffer * buf, GstPad * pad,
    gpointer data)
{
  GAsyncQueue *queue_input_buf = NULL;
  GAsyncQueue *queue_output_buf = NULL;

  /* ref then push buffer to use it in sdl */
  gst_buffer_ref (buf);
  queue_input_buf =
      (GAsyncQueue *) g_object_get_data (G_OBJECT (fakesink),
      "queue_input_buf");
  g_async_queue_push (queue_input_buf, buf);
  if (g_async_queue_length (queue_input_buf) > 3)
    g_idle_add (update_sdl_scene, (gpointer) fakesink);

  /* pop then unref buffer we have finished to use in sdl */
  queue_output_buf =
      (GAsyncQueue *) g_object_get_data (G_OBJECT (fakesink),
      "queue_output_buf");
  if (g_async_queue_length (queue_output_buf) > 3) {
    GstBuffer *buf_old = (GstBuffer *) g_async_queue_pop (queue_output_buf);
    gst_buffer_unref (buf_old);
  }
}
Exemplo n.º 4
0
/**
 * I suppose I won't overflow the Input queue but check it anyway.
 * The Output queue might get overflowed in case of very long frame
 * processing delay or something, causing the messages not be consumed
 * on the other end.
 */
gboolean
_tf_allegro_check_overflow (struct TfAlTimerState *tf)
{
  if (1000 > g_async_queue_length (tf->qu_out) ||
      1000 > g_async_queue_length (tf->qu_in))
      return TRUE;
  return FALSE;
}
static gboolean
sort_queue (gpointer user_data)
{
  static gint     sorts = 0;
  static gpointer last_p = NULL;
  gpointer        p;
  gboolean        can_quit = FALSE;
  gint            sort_multiplier;
  gint            len;
  gint            i;

  sort_multiplier = GPOINTER_TO_INT (user_data);

  if (SORT_QUEUE_AFTER) {
    PRINT_MSG (("sorting async queue...")); 
    g_async_queue_sort (async_queue, sort_compare, NULL);

    sorts++;

    if (sorts >= sort_multiplier) {
      can_quit = TRUE;
    }
    
    g_async_queue_sort (async_queue, sort_compare, NULL);
    len = g_async_queue_length (async_queue);

    PRINT_MSG (("sorted queue (for %d/%d times, size:%d)...", sorts, MAX_SORTS, len)); 
  } else {
    can_quit = TRUE;
    len = g_async_queue_length (async_queue);
    DEBUG_MSG (("printing queue (size:%d)...", len)); 
  }

  for (i = 0, last_p = NULL; i < len; i++) {
    p = g_async_queue_pop (async_queue);
    DEBUG_MSG (("item %d ---> %d", i, GPOINTER_TO_INT (p))); 

    if (last_p) {
      g_assert (GPOINTER_TO_INT (last_p) <= GPOINTER_TO_INT (p));
    }

    last_p = p;
  }
  
  if (can_quit && QUIT_WHEN_DONE) {
    g_main_loop_quit (main_loop);
  }

  return !can_quit;
}
G_GNUC_INTERNAL
void
_mdw_default_player_display_finalize(MdwDefaultPlayerDisplay** p_display)
{
    g_assert(p_display != NULL && *p_display != NULL);
    MdwDefaultPlayerDisplay* display = *p_display;

    DEBUG_INFO("Deinitializing DirectFB"); 
    if (display->directfb_thread) {
        MdwMessage* m = mdw_message_new(MDW_MESSAGE_TYPE_FINALIZE, 0);
        mdw_message_put(m, display->directfb_queue);
        g_assert(display->main_queue != NULL);
        m = mdw_message_get(display->main_queue, TRUE);
        if (m->type == MDW_MESSAGE_TYPE_FINALIZED) {
            /* deinitialized */
            /* g_thread_join ? */
        } else {
            DEBUG_ERROR("directfb_thread did not return MDW_MESSAGE_TYPE_FINALIZED");
            g_assert_not_reached();
        }
        g_assert(g_async_queue_length(display->main_queue) == 0);
        g_assert(g_async_queue_length(display->directfb_queue) == 0);
    }
    if (display->surface) {
        display->surface->Release(display->surface);
    }
    if (display->window) {
        display->window->Release(display->window);
    }
    if (display->layer) {
        display->layer->Release(display->layer);
    }
    if (display->dfb) {
        display->dfb->Release(display->dfb);
    }
    DEBUG_INFO("DirectFB released"); 
    if (display->main_queue) {
        g_assert(g_async_queue_length(display->main_queue) == 0);
        g_async_queue_unref(display->main_queue);
    }
    if (display->directfb_queue) {
        g_assert(g_async_queue_length(display->directfb_queue) == 0);
        g_async_queue_unref(display->directfb_queue);
    }
    g_free(display);
    *p_display = NULL;

}
static void
enter_thread (gpointer data, gpointer user_data)
{
  gint   len;
  gint   id;
  gulong ms;

  id = GPOINTER_TO_INT (data);
  
  ms = g_random_int_range (MIN_TIME * 1000, MAX_TIME * 1000);
  DEBUG_MSG (("entered thread with id:%d, adding to queue in:%ld ms", id, ms));

  g_usleep (ms * 1000);

  if (SORT_QUEUE_ON_PUSH) {
    g_async_queue_push_sorted (async_queue, GINT_TO_POINTER (id), sort_compare, NULL);
  } else {
    g_async_queue_push (async_queue, GINT_TO_POINTER (id));
  }

  len = g_async_queue_length (async_queue);

  DEBUG_MSG (("thread id:%d added to async queue (size:%d)", 
	     id, len));
}
Exemplo n.º 8
0
gint
network_server_pending_events(struct network_server_s *srv)
{
	if (NULL == srv || NULL == srv->queue_events)
		return G_MAXINT;
	return g_async_queue_length(srv->queue_events);
}
Exemplo n.º 9
0
static guint
_start_necessary_threads(struct network_server_s *srv)
{
	guint count = 0;
	gint length;

	if (!srv->flag_continue)
		return 0;

	for (; _thread_must_start(srv) ;count++)
		_server_start_one_worker(srv, TRUE);

	while (srv->flag_continue) {
		length = g_async_queue_length(srv->queue_events);
		if (length < 0)
			break;
		if (((guint)length) < srv->workers_total)
			break;
		if (!_thread_can_start(srv))
			break;
		_server_start_one_worker(srv, TRUE);
		count ++;
	}

	return count;
}
Exemplo n.º 10
0
static gboolean
thread_events_check (GSource *source)
{
    UNUSED (source);

    return g_async_queue_length (thread_events_queue) > 0;
}
G_GNUC_INTERNAL
void
_mdw_default_player_display_show_picture(
    MdwDefaultPlayerDisplay* display, 
    const void* picture, 
    const guint width, const guint height, const guint bytes_per_pixel) 
{
    g_assert(display != NULL);
    g_assert(picture != NULL);
    g_assert(width != 0);
    g_assert(height != 0);
    g_assert(bytes_per_pixel != 0);
    

    MdwMessage* m = mdw_message_new(MDW_MESSAGE_TYPE_DISPLAY_FRAME, sizeof(struct picture));
    struct picture* p = (struct picture*) m->buffer;
    p->data = g_memdup(picture, width * height * bytes_per_pixel);
    p->width = width;
    p->height = height;
    p->bytes_per_pixel = bytes_per_pixel;
    g_assert(display->directfb_queue != NULL);
    
    mdw_message_put(m, display->directfb_queue);

    while(g_async_queue_length(display->directfb_queue) > 30) {
        usleep(10);
    }
}
Exemplo n.º 12
0
static SaErrorT harvest_events_for_handler(struct oh_handler *h)
{
        struct oh_event event;
        struct oh_event *e2;
        struct oh_global_param param = { .type = OPENHPI_EVT_QUEUE_LIMIT };

        SaErrorT error = SA_OK;

        if (oh_get_global_param(&param))
                param.u.evt_queue_limit = OH_MAX_EVT_QUEUE_LIMIT;

        do {
                error = h->abi->get_event(h->hnd, &event);
                if (error < 1) {
                        trace("Handler is out of Events");
                } else if (param.u.evt_queue_limit != OH_MAX_EVT_QUEUE_LIMIT &&
                           g_async_queue_length(oh_process_q) >= param.u.evt_queue_limit) {
                        dbg("Process queue is out of space");
                        return SA_ERR_HPI_OUT_OF_SPACE;
                } else {
                        trace("Found event for handler %p", h);
                        e2 = oh_dup_oh_event(&event);
                        e2->hid = h->id;
                        g_async_queue_push(oh_process_q, e2);
                }
        } while(error > 0);

        return SA_OK;
}
gboolean ms_scan_thread(void *data)
{
	ms_scan_data_t *scan_data = NULL;
	ms_scan_data_t *insert_data;
	GArray *garray = NULL;
	bool res;
	int length;
	int err;
	void **handle = NULL;
	ms_storage_type_t storage_type;
	ms_dir_scan_type_t scan_type;

	/*create array for processing overlay data*/
	garray = g_array_new (FALSE, FALSE, sizeof (ms_scan_data_t *));
	if (garray == NULL) {
		MS_DBG_ERR("g_array_new error");
		return false;
	}

	while (1) {
		length  = g_async_queue_length(scan_queue);

		/*updating requests remain*/
		if (garray->len != 0 && length == 0) {
			scan_data = g_array_index(garray, ms_scan_data_t*, 0);
			g_array_remove_index (garray, 0);
			if (scan_data->scan_type == POWEROFF) {
				MS_DBG("power off");
				goto POWER_OFF;
			}
		} else if (length != 0) {
Exemplo n.º 14
0
static void 
mdw_dvb_demux_thread_read_write_go(MdwDvbDemux *self) 
{
    g_assert(self != NULL);
    MdwDvbDemuxPrivate *priv = MDW_DVB_DEMUX_GET_PRIVATE(self);
    if (priv->thread_read_write == NULL) {
        mdw_dvb_demux_thread_read_write_init(self);
        g_assert(priv->thread_read_write != NULL);
        g_assert(priv->main_queue != NULL);
        g_assert(priv->thread_read_write_queue != NULL);
    }

    DEBUG_INFO("Asking to activate thread to read/write ");
    MdwMessage *m = mdw_message_new(MDW_MESSAGE_TYPE_GO, 0);
    mdw_message_put(m, priv->thread_read_write_queue);
    
    m = mdw_message_get(priv->main_queue, TRUE);
    g_assert(m->type == MDW_MESSAGE_TYPE_GOING);
    g_assert(m->buffer == NULL);
    g_assert(m->size == 0);
    mdw_message_free(m, TRUE);

    g_assert(g_async_queue_length(priv->main_queue) == 0); 

}
Exemplo n.º 15
0
static gboolean
completed_check(GSource* base)
{
	GckCallSource *source = (GckCallSource*)base;
	g_assert (source->klass->completed_queue);
	return g_async_queue_length (source->klass->completed_queue) > 0;
}
Exemplo n.º 16
0
static void 
mdw_dvb_demux_thread_read_write_init(MdwDvbDemux *self) 
{
    g_assert(self != NULL);
    MdwDvbDemuxPrivate *priv = MDW_DVB_DEMUX_GET_PRIVATE(self);
    g_assert(priv->thread_read_write == NULL);
    g_assert(priv->main_queue == NULL);
    g_assert(priv->thread_read_write_queue == NULL);

    if(!g_thread_supported()) g_thread_init (NULL);
   
    DEBUG_INFO("Initing thread to read/write");
    priv->thread_read_write = g_thread_create(_thread_read_write_func, self, FALSE, NULL);
    priv->main_queue = g_async_queue_new();
    priv->thread_read_write_queue = g_async_queue_new();
    
    //MdwMessage *m = mdw_message_new();
    //mdw_message_put(m, priv->main_queue);
    //
    /* wait for init */
    MdwMessage *m = mdw_message_get(priv->main_queue, TRUE);
    
    g_assert(m->type == MDW_MESSAGE_TYPE_READY);
    g_assert(m->buffer == NULL);
    g_assert(m->size == 0);
    mdw_message_free(m, TRUE);
    
    g_assert(g_async_queue_length(priv->main_queue) == 0);
    
}
Exemplo n.º 17
0
static void
_gck_call_base_finalize (GckCallClass *klass)
{
	GMainContext *context;
	GSource *src;

	if (klass->thread_pool) {
		g_assert (g_thread_pool_unprocessed (klass->thread_pool) == 0);
		g_thread_pool_free (klass->thread_pool, FALSE, TRUE);
		klass->thread_pool = NULL;
	}

	if (klass->completed_id) {
		context = g_main_context_default ();
		g_return_if_fail (context);

		src = g_main_context_find_source_by_id (context, klass->completed_id);
		g_assert (src);
		g_source_destroy (src);
		klass->completed_id = 0;
	}

	if (klass->completed_queue) {
		g_assert (g_async_queue_length (klass->completed_queue));
		g_async_queue_unref (klass->completed_queue);
		klass->completed_queue = NULL;
	}
}
Exemplo n.º 18
0
void
arv_stream_get_n_buffers (ArvStream *stream, gint *n_input_buffers, gint *n_output_buffers)
{
	if (!ARV_IS_STREAM (stream)) {
		if (n_input_buffers != NULL)
			*n_input_buffers = 0;
		if (n_output_buffers != NULL)
			*n_output_buffers = 0;
		return;
	}

	if (n_input_buffers != NULL)
		*n_input_buffers = g_async_queue_length (stream->priv->input_queue);
	if (n_output_buffers != NULL)
		*n_output_buffers = g_async_queue_length (stream->priv->output_queue);
}
Exemplo n.º 19
0
/**
 * oh_destroy_session
 * @sid:
 * @update_domain:
 *
 *
 * Returns:
 **/
SaErrorT oh_destroy_session(SaHpiSessionIdT sid)
{
        struct oh_session *session = NULL;
        gpointer event = NULL;
        int i, len;

        if (sid < 1)
                return SA_ERR_HPI_INVALID_PARAMS;

        wrap_g_static_rec_mutex_lock(&oh_sessions.lock); /* Locked session table */
        session = g_hash_table_lookup(oh_sessions.table, &sid);
        if (!session) {
                wrap_g_static_rec_mutex_unlock(&oh_sessions.lock);
                return SA_ERR_HPI_INVALID_SESSION;
        }
        oh_sessions.list = g_slist_remove(oh_sessions.list, session);
        g_hash_table_remove(oh_sessions.table, &(session->id));
        wrap_g_static_rec_mutex_unlock(&oh_sessions.lock); /* Unlocked session table */

        /* Finalize session */
        len = g_async_queue_length(session->eventq);
        if (len > 0) {
                for (i = 0; i < len; i++) {
                        event = g_async_queue_try_pop(session->eventq);
                        if (event)
                                oh_event_free(event, FALSE);
                        event = NULL;
                }
        }
        g_async_queue_unref(session->eventq);
        g_free(session);

        return SA_OK;
}
Exemplo n.º 20
0
static void
tag_reader_finalize (GObject *object)
{
    TagReader *self = TAG_READER (object);

    self->priv->run = FALSE;

    while (g_async_queue_length (self->priv->job_queue) > 0) {
        QueueEntry *entry = g_async_queue_try_pop (self->priv->job_queue);

        if (!entry) {
            continue;
        }

        if (entry->location) {
            g_free (entry->location);
        }
        if (entry->mtype) {
            g_free (entry->mtype);
        }
        g_free (entry);
    }

    g_async_queue_push (self->priv->job_queue, NULL);
    g_thread_join (self->priv->job_thread);

    g_async_queue_unref (self->priv->job_queue);

    G_OBJECT_CLASS (tag_reader_parent_class)->finalize (object);
}
Exemplo n.º 21
0
static void save_dump(global_conf_st *g_conf)
{
    FILE *fp = NULL;
    xode msg = NULL;
    char *msg_str = NULL;
    int i;
    if (g_conf->reload_file)
    {
	fp = fopen(g_conf->reload_file, "a+");
	if (fp == NULL)
	{
	    jlog(L_DEBUG, "try to create %s error\n", g_conf->reload_file);
	    global_conf_free(g_conf);
	    exit(-1);
	}
	for (i = 0; i < g_conf->max_thread; i++)
	{
	    while (g_async_queue_length(threads[i].msg_queue) > 0)
	    {
		msg = (xode) g_async_queue_pop(threads[i].msg_queue);
		decrMsgProcNum();
		msg_str = xode_to_str(msg);
		if (msg_str && (!is_blank_line(msg_str)))
		{
		    fprintf(fp, "%s\n", msg_str);
		    jlog(L_DEBUG, "save %s\n", msg_str);
		}
		xode_free(msg);
	    }
	}
	fclose(fp);
    }
}
Exemplo n.º 22
0
int main(int argc, char *argv[])
{
    char ch;
    if(argc < 2){
	fprintf(stderr,"Usage: ./link_mining -f ../conf/link_mining.xml");
	return 1;
    }
    int is_daemon = 1;
    global_conf_st *g_conf = NULL;
    g_conf = (global_conf_st *)calloc(sizeof(global_conf_st),1);
    set_default_conf(g_conf);
    while( -1 != (ch = getopt(argc,argv,"f:h:?:D"))){
	switch(ch){
	case 'f':
	    init_global_config(g_conf,optarg);
	    break;
	case 'D':
	    is_daemon = 0;
	    break;
	case 'h':
	case '?':
	default:
	    fprintf(stderr,"Usage ./link_ming -f ../conf/link_mining.xml");
	}
    }
    g_thread_init(NULL);
    signal(SIGINT,signal_handler);
    signal(SIGTERM,signal_handler);
    signal(SIGHUP,signal_handler);
    signal(SIGPIPE,SIG_IGN);
    if(is_daemon && (daemon(0,0) == -1)){
	jlog(L_ERR,"daemon error");
    }
    thread_init(g_conf);
    MSG_PROCESSING = 0;
    reload_dump(g_conf);
    pthread_t receive_ppid;
    receive_ppid = init_receive_thread(g_conf);
    int i;
    while(!is_shutdown){
	sleep(1);
    }
    save_dump(g_conf);
    pthread_join(receive_ppid,NULL);
    save_dump(g_conf);
    int len = 0;
    for(i = 0;i<g_conf->max_thread;i++){
	len = g_async_queue_length(threads[i].msg_queue);
	jlog(L_DEBUG,"(%d)len: %d",i,len);
	pthread_cancel(threads[i].ppid);
    }
    pthread_mutex_lock(&init_lock);
    while(init_count >0)
	pthread_cond_wait(&init_cond,&init_lock);
    pthread_mutex_unlock(&init_lock);

    global_conf_free(g_conf);
    return 0;
}
Exemplo n.º 23
0
/**
 * Check the source, after polling.
 * @return TRUE if there's something on the queue
 */
static gboolean result_queue_source_check(GSource *source)
{
        struct result_queue *queue;

        g_return_val_if_fail(source, FALSE);
        queue = (struct result_queue *)source;
        return g_async_queue_length(queue->async_queue)>0;
}
Exemplo n.º 24
0
static gboolean
thread_events_prepare (GSource *source, gint *timeout)
{
    UNUSED (source);

    *timeout = -1;
    return g_async_queue_length (thread_events_queue) > 0;
}
Exemplo n.º 25
0
static gboolean
message_queue_source_prepare (GSource *source,
                              gint    *timeout_)
{
  MessageQueueSource *message_queue_source = (MessageQueueSource *) source;

  return (g_async_queue_length (message_queue_source->queue) > 0);
}
Exemplo n.º 26
0
static
gboolean _queue_check(GSource *source)
{
  OSyncQueue *queue = *((OSyncQueue **)(source + 1));
  if (g_async_queue_length(queue->outgoing) > 0)
    return TRUE;
  return FALSE;
}
Exemplo n.º 27
0
/**
 * Returns the number of jobs left
 */
gint
rs_io_get_jobs_left(void)
{
	g_static_mutex_lock(&count_lock);
	gint left = g_async_queue_length(queue) + queue_active_count;
	g_static_mutex_unlock(&count_lock);
	return left;
}
Exemplo n.º 28
0
static gboolean
handle_queued_objects (APP_STATE_T * state)
{
    GstMiniObject *object = NULL;

    g_mutex_lock (&state->queue_lock);
    if (state->flushing) {
        g_cond_broadcast (&state->cond);
        goto beach;
    } else if (g_async_queue_length (state->queue) == 0) {
        goto beach;
    }

    if ((object = g_async_queue_try_pop (state->queue))) {
        if (GST_IS_BUFFER (object)) {
            GstBuffer *buffer = GST_BUFFER_CAST (object);
            update_image (state, buffer);
            render_scene (state);
            gst_buffer_unref (buffer);
            if (!SYNC_BUFFERS) {
                object = NULL;
            }
        } else if (GST_IS_QUERY (object)) {
            GstQuery *query = GST_QUERY_CAST (object);
            GstStructure *s = (GstStructure *) gst_query_get_structure (query);

            if (gst_structure_has_name (s, "not-used")) {
                g_assert_not_reached ();
            } else {
                g_assert_not_reached ();
            }
        } else if (GST_IS_EVENT (object)) {
            GstEvent *event = GST_EVENT_CAST (object);
            g_print ("\nevent %p %s\n", event,
                     gst_event_type_get_name (GST_EVENT_TYPE (event)));

            switch (GST_EVENT_TYPE (event)) {
            case GST_EVENT_EOS:
                flush_internal (state);
                break;
            default:
                break;
            }
            gst_event_unref (event);
            object = NULL;
        }
    }

    if (object) {
        state->popped_obj = object;
        g_cond_broadcast (&state->cond);
    }

beach:
    g_mutex_unlock (&state->queue_lock);

    return FALSE;
}
Exemplo n.º 29
0
static gboolean
_q_is_stalled (struct oio_events_queue_s *self)
{
	struct _queue_AGENT_s *q = (struct _queue_AGENT_s*) self;
	EXTRA_ASSERT (q != NULL && q->vtable == &vtable_AGENT);
	const int l = g_async_queue_length (q->queue);
	const guint waiting = q->gauge_pending;
	return (waiting + (guint)(l>0?l:0)) >= q->max_events_in_queue;
}
Exemplo n.º 30
0
/**
 * Before source content are polled.
 *
 * *timeout is always set to -1, since we rely on
 * g_main_context_wakeup to wake up the loop when
 * there's a new result
 *
 * @param source
 * @param timeout maximum timeout to pass to the poll() call (out)
 * @return TRUE if there's something on the queue
 */
static gboolean result_queue_source_prepare(GSource *source, gint *timeout)
{
        struct result_queue *queue;

        g_return_val_if_fail(source, FALSE);
        queue = (struct result_queue *)source;
        *timeout=-1;
        return g_async_queue_length(queue->async_queue)>0;
}