Ejemplo n.º 1
0
QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context)
    : mainContext(context)
{
    if (qgetenv("QT_NO_THREADED_GLIB").isEmpty()) {
        static int dummyValue = 0; // only used for its address
        QMutexLocker locker(QMutexPool::instance()->get(&dummyValue));
        if (!g_thread_supported())
            g_thread_init(NULL);
    }

    if (mainContext) {
        g_main_context_ref(mainContext);
    } else {
        QCoreApplication *app = QCoreApplication::instance();
        if (app && QThread::currentThread() == app->thread()) {
            mainContext = g_main_context_default();
            g_main_context_ref(mainContext);
        } else {
            mainContext = g_main_context_new();
        }
    }

#if GLIB_CHECK_VERSION (2, 22, 0)
    g_main_context_push_thread_default (mainContext);
#endif

    // setup post event source
    postEventSource = reinterpret_cast<GPostEventSource *>(g_source_new(&postEventSourceFuncs,
                                                                        sizeof(GPostEventSource)));
    postEventSource->serialNumber = 1;
    postEventSource->d = this;
    g_source_set_can_recurse(&postEventSource->source, true);
    g_source_attach(&postEventSource->source, mainContext);

    // setup socketNotifierSource
    socketNotifierSource =
        reinterpret_cast<GSocketNotifierSource *>(g_source_new(&socketNotifierSourceFuncs,
                                                               sizeof(GSocketNotifierSource)));
    (void) new (&socketNotifierSource->pollfds) QList<GPollFDWithQSocketNotifier *>();
    g_source_set_can_recurse(&socketNotifierSource->source, true);
    g_source_attach(&socketNotifierSource->source, mainContext);

    // setup normal and idle timer sources
    timerSource = reinterpret_cast<GTimerSource *>(g_source_new(&timerSourceFuncs,
                                                                sizeof(GTimerSource)));
    (void) new (&timerSource->timerList) QTimerInfoList();
    timerSource->processEventsFlags = QEventLoop::AllEvents;
    timerSource->runWithIdlePriority = false;
    g_source_set_can_recurse(&timerSource->source, true);
    g_source_attach(&timerSource->source, mainContext);

    idleTimerSource = reinterpret_cast<GIdleTimerSource *>(g_source_new(&idleTimerSourceFuncs,
                                                                        sizeof(GIdleTimerSource)));
    idleTimerSource->timerSource = timerSource;
    g_source_set_can_recurse(&idleTimerSource->source, true);
    g_source_set_priority(&idleTimerSource->source, G_PRIORITY_DEFAULT_IDLE);
    g_source_attach(&idleTimerSource->source, mainContext);
}
Ejemplo n.º 2
0
void RunLoop::wakeUp()
{
    GRefPtr<GSource> source = adoptGRef(g_idle_source_new());
    g_source_set_priority(source.get(), G_PRIORITY_DEFAULT);
    g_source_set_callback(source.get(), reinterpret_cast<GSourceFunc>(&RunLoop::queueWork), this, 0);
    g_source_attach(source.get(), m_runLoopContext.get());

    g_main_context_wakeup(m_runLoopContext.get());
}
KeyboardEventRepeating::KeyboardEventRepeating(Client& client)
    : m_client(client)
{
    m_source = g_source_new(&sourceFuncs, sizeof(GSource));
    g_source_set_name(m_source, "[WPE] KeyboardEventRepeating");
    g_source_set_priority(m_source, G_PRIORITY_DEFAULT_IDLE);
    g_source_set_callback(m_source, nullptr, this, nullptr);
    g_source_attach(m_source, g_main_context_get_thread_default());
}
Ejemplo n.º 4
0
static void
cockpit_close_later (CockpitStream *self)
{
  GSource *source = g_idle_source_new ();
  g_source_set_priority (source, G_PRIORITY_HIGH);
  g_source_set_callback (source, on_later_close, g_object_ref (self), g_object_unref);
  g_source_attach (source, g_main_context_get_thread_default ());
  g_source_unref (source);
}
Ejemplo n.º 5
0
GSource *
g_connect_source_new(gint fd)
{
  GConnectSource *self = (GConnectSource *) g_source_new(&g_connect_source_funcs, sizeof(GConnectSource));

  self->pollfd.fd = fd;  
  g_source_set_priority(&self->super, LOG_PRIORITY_CONNECT);
  g_source_add_poll(&self->super, &self->pollfd);
  return &self->super;
}
Ejemplo n.º 6
0
static void
glib_ctx_break(verto_mod_ctx *ctx)
{
    GSource *src = g_timeout_source_new(0);
    g_assert(src);
    g_source_set_callback(src, break_callback, ctx->loop, NULL);
    g_source_set_priority(src, G_PRIORITY_HIGH);
    g_assert(g_source_attach(src, ctx->context) != 0);
    g_source_unref(src);
}
Ejemplo n.º 7
0
GSource *
g_listen_source_new(gint fd)
{
  GListenSource *self = (GListenSource *) g_source_new(&g_listen_source_funcs, sizeof(GListenSource));

  self->pollfd.fd = fd;  
  g_source_set_priority(&self->super, LOG_PRIORITY_LISTEN);
  g_source_add_poll(&self->super, &self->pollfd);
  return &self->super;
}
Ejemplo n.º 8
0
/**
 * soup_add_completion:
 * @async_context: the #GMainContext to dispatch the idle event in, or
 * %NULL for the default context
 * @function: the callback to invoke
 * @data: user data to pass to @function
 *
 * Adds @function to be executed from inside @async_context with the
 * default priority. Use this when you want to complete an action in
 * @async_context's main loop, as soon as possible.
 *
 * Return value: a #GSource, which can be removed from @async_context
 * with g_source_destroy().
 *
 * Since: 2.24
 **/
GSource *
soup_add_completion (GMainContext *async_context,
	             GSourceFunc function, gpointer data)
{
	GSource *source = g_idle_source_new ();
	g_source_set_priority (source, G_PRIORITY_DEFAULT);
	g_source_set_callback (source, function, data, NULL);
	g_source_attach (source, async_context);
	g_source_unref (source);
	return source;
}
Ejemplo n.º 9
0
void
meta_wayland_init (void)
{
  MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
  GSource *wayland_event_source;

  if (!wl_global_create (compositor->wayland_display,
			 &wl_compositor_interface,
			 META_WL_COMPOSITOR_VERSION,
			 compositor, compositor_bind))
    g_error ("Failed to register the global wl_compositor");

  wayland_event_source = wayland_event_source_new (compositor->wayland_display);

  /* XXX: Here we are setting the wayland event source to have a
   * slightly lower priority than the X event source, because we are
   * much more likely to get confused being told about surface changes
   * relating to X clients when we don't know what's happened to them
   * according to the X protocol.
   *
   * At some point we could perhaps try and get the X protocol proxied
   * over the wayland protocol so that we don't have to worry about
   * synchronizing the two command streams. */
  g_source_set_priority (wayland_event_source, GDK_PRIORITY_EVENTS + 1);
  g_source_attach (wayland_event_source, NULL);

  wl_display_init_shm (compositor->wayland_display);

  meta_wayland_outputs_init (compositor);
  meta_wayland_data_device_manager_init (compositor);
  meta_wayland_shell_init (compositor);
  meta_wayland_seat_init (compositor);

  /* FIXME: find the first free name instead */
  compositor->display_name = wl_display_add_socket_auto (compositor->wayland_display);
  if (compositor->display_name == NULL)
    g_error ("Failed to create socket");

  /* XXX: It's important that we only try and start xwayland after we
   * have initialized EGL because EGL implements the "wl_drm"
   * interface which xwayland requires to determine what drm device
   * name it should use.
   *
   * By waiting until we've shown the stage above we ensure that the
   * underlying GL resources for the surface have also been allocated
   * and so EGL must be initialized by this point.
   */

  if (!meta_xwayland_start (&compositor->xwayland_manager, compositor->wayland_display))
    g_error ("Failed to start X Wayland");

  set_gnome_env ("DISPLAY", meta_wayland_get_xwayland_display_name (compositor));
  set_gnome_env ("WAYLAND_DISPLAY", meta_wayland_get_wayland_display_name (compositor));
}
Ejemplo n.º 10
0
void
frida_unref (gpointer obj)
{
  GSource * source;

  source = g_idle_source_new ();
  g_source_set_priority (source, G_PRIORITY_HIGH);
  g_source_set_callback (source, dummy_callback, obj, g_object_unref);
  g_source_attach (source, main_context);
  g_source_unref (source);
}
Ejemplo n.º 11
0
void GMainLoopSource::scheduleIdleSource(const char* name, GSourceFunc sourceFunction, int priority, GMainContext* context)
{
    ASSERT(m_status == Ready);
    m_status = Scheduled;

    g_source_set_name(m_context.source.get(), name);
    if (priority != G_PRIORITY_DEFAULT_IDLE)
        g_source_set_priority(m_context.source.get(), priority);
    g_source_set_callback(m_context.source.get(), sourceFunction, this, nullptr);
    g_source_attach(m_context.source.get(), context);
}
Ejemplo n.º 12
0
static void CALEStartEventLoop(void * data)
{
    CALEContext * const context = data;

    assert(context != NULL);

    // Create the event loop.
    GMainContext * const loop_context = g_main_context_new();
    GMainLoop * const event_loop = g_main_loop_new(loop_context, FALSE);

    g_main_context_push_thread_default(loop_context);

    /*
      We have to do the BlueZ object manager client initialization and
      signal subscription here so that the corresponding asynchronous
      signal handling occurs in the same thread as the one running the
      GLib event loop.
    */
    if (CALESetUpDBus(&g_context))
    {
        ca_mutex_lock(context->lock);

        assert(context->event_loop == NULL);
        context->event_loop = event_loop;

        ca_mutex_unlock(context->lock);

        /*
          Add an idle handler that notifies a thread waiting for the
          GLib event loop to run that the event loop is actually
          running.  We do this in the context of the event loop itself
          to avoid race conditions.
        */
        GSource * const source = g_idle_source_new();
        g_source_set_priority(source, G_PRIORITY_HIGH_IDLE);
        g_source_set_callback(source,
                              CALEEventLoopStarted,
                              &context->le_started,  // data
                              NULL);                 // notify
        (void) g_source_attach(source, loop_context);
        g_source_unref(source);

        g_main_loop_run(event_loop);  // Blocks until loop is quit.

        CALETearDownDBus(&g_context);
    }

    /*
      Clean up in the same thread to avoid having to explicitly bump
      the ref count to retain ownership.
    */
    g_main_context_unref(loop_context);
    g_main_loop_unref(event_loop);
}
Ejemplo n.º 13
0
static LogReaderWatch *
log_reader_watch_new(LogReader *reader, LogProto *proto)
{
  LogReaderWatch *self = (LogReaderWatch *) g_source_new(&log_reader_source_funcs, sizeof(LogReaderWatch));
  
  log_pipe_ref(&reader->super.super);
  self->reader = reader;
  self->proto = proto;
  g_source_set_priority(&self->super, LOG_PRIORITY_READER);
  g_source_add_poll(&self->super, &self->pollfd);
  return self;
}
Ejemplo n.º 14
0
static void
glib_ctx_set_flags(verto_mod_ctx *ctx, const verto_ev *ev, verto_mod_ev *evpriv)
{
    if (verto_get_flags(ev) & VERTO_EV_FLAG_PRIORITY_HIGH)
        g_source_set_priority(evpriv, G_PRIORITY_HIGH);
    else if (verto_get_flags(ev) & VERTO_EV_FLAG_PRIORITY_MEDIUM)
        g_source_set_priority(evpriv, G_PRIORITY_DEFAULT_IDLE);
    else if (verto_get_flags(ev) & VERTO_EV_FLAG_PRIORITY_LOW)
        g_source_set_priority(evpriv, G_PRIORITY_LOW);

    if (verto_get_type(ev) == VERTO_EV_TYPE_IO) {
        ((GIOSource*) evpriv)->fd.events = 0;

        if (verto_get_flags(ev) & VERTO_EV_FLAG_IO_READ)
            ((GIOSource*) evpriv)->fd.events |= G_IO_IN  | G_IO_PRI | G_IO_ERR |
                                                G_IO_HUP | G_IO_NVAL;
        if (verto_get_flags(ev) & VERTO_EV_FLAG_IO_WRITE)
            ((GIOSource*) evpriv)->fd.events |= G_IO_OUT | G_IO_ERR |
                                                G_IO_HUP | G_IO_NVAL;
    }
}
Ejemplo n.º 15
0
void owl_select_post_task(void (*cb)(void*), void *cbdata, void (*destroy_cbdata)(void*), GMainContext *context)
{
  GSource *source = g_idle_source_new();
  owl_task *t = g_new0(owl_task, 1);
  t->cb = cb;
  t->cbdata = cbdata;
  t->destroy_cbdata = destroy_cbdata;
  g_source_set_priority(source, G_PRIORITY_DEFAULT);
  g_source_set_callback(source, _run_task, t, _destroy_task);
  g_source_attach(source, context);
  g_source_unref(source);
}
Ejemplo n.º 16
0
/* Handle the kAEOpenDocuments Apple events. This will register
 * an idle source callback for each filename in the event.
 */
static pascal OSErr
gui_unique_mac_open_documents (const AppleEvent *inAppleEvent,
                               AppleEvent       *outAppleEvent,
                               long              handlerRefcon)
{
  OSStatus    status;
  AEDescList  documents;
  gchar       path[MAXPATHLEN];

  status = AEGetParamDesc (inAppleEvent,
                           keyDirectObject, typeAEList,
                           &documents);
  if (status == noErr)
    {
      long count = 0;
      int  i;

      AECountItems (&documents, &count);

      for (i = 0; i < count; i++)
        {
          FSRef    ref;
          gchar    *callback_path;
          GSource  *source;
          GClosure *closure;

          status = AEGetNthPtr (&documents, i + 1, typeFSRef,
                                0, 0, &ref, sizeof (ref),
                                0);
          if (status != noErr)
            continue;

          FSRefMakePath (&ref, (UInt8 *) path, MAXPATHLEN);

          callback_path = g_strdup (path);

          closure = g_cclosure_new (G_CALLBACK (gui_unique_mac_idle_open),
                                    (gpointer) callback_path,
                                    (GClosureNotify) g_free);

          g_object_watch_closure (G_OBJECT (unique_gimp), closure);

          source = g_idle_source_new ();
          g_source_set_priority (source, G_PRIORITY_LOW);
          g_source_set_closure (source, closure);
          g_source_attach (source, NULL);
          g_source_unref (source);
        }
    }

    return status;
}
Ejemplo n.º 17
0
static gint64
get_sleep_serial (void)
{
  if (sleep_source == NULL)
    {
      sleep_source = g_source_new (&sleep_source_funcs, sizeof (GSource));

      g_source_set_priority (sleep_source, G_PRIORITY_HIGH);
      g_source_attach (sleep_source, NULL);
      g_source_unref (sleep_source);
    }

  return sleep_serial;
}
Ejemplo n.º 18
0
  static GSource *
log_writer_watch_new(LogWriter *writer, LogProto *proto)
{
  LogWriterWatch *self = (LogWriterWatch *) g_source_new(&log_writer_source_funcs, sizeof(LogWriterWatch));

  self->writer = writer;
  self->proto = proto;
  log_pipe_ref(&self->writer->super);
  g_source_set_priority(&self->super, LOG_PRIORITY_WRITER);

  if ((writer->flags & LW_ALWAYS_WRITABLE) == 0)
    g_source_add_poll(&self->super, &self->pollfd);
  return &self->super;
}
Ejemplo n.º 19
0
void
xt_client_xloop_create(void)
{
  /* If this is the first running widget, hook this display into the
     mainloop */
  if (0 == num_widgets) {
    int cnumber;
    GSource* gs;

    /* Set up xtdisplay in case we're missing one */
    if (!xtdisplay) {
      (void)xt_client_get_display();
    }

    /*
     * hook Xt event loop into the glib event loop.
     */
    /* the assumption is that gtk_init has already been called */
    gs = g_source_new(&xt_event_funcs, sizeof(GSource));
    if (!gs) {
      return;
    }

    g_source_set_priority(gs, GDK_PRIORITY_EVENTS);
    g_source_set_can_recurse(gs, TRUE);
    tag = g_source_attach(gs, (GMainContext*)NULL);
    g_source_unref(gs);
#ifdef VMS
    cnumber = XConnectionNumber(xtdisplay);
#else
    cnumber = ConnectionNumber(xtdisplay);
#endif
    xt_event_poll_fd.fd = cnumber;
    xt_event_poll_fd.events = G_IO_IN; 
    xt_event_poll_fd.revents = 0;    /* hmm... is this correct? */

    g_main_context_add_poll ((GMainContext*)NULL, 
                             &xt_event_poll_fd, 
                             G_PRIORITY_LOW);
    /* add a timer so that we can poll and process Xt timers */
    xt_polling_timer_id =
      g_timeout_add(25,
                    (GtkFunction)xt_event_polling_timer_callback,
                    xtdisplay);
  }

  /* Bump up our usage count */
  num_widgets++;
}
Ejemplo n.º 20
0
void gdk_android_events_init()
{
    static GSourceFuncs event_funcs = {
        gdk_android_event_prepare,
        gdk_android_event_check,
        gdk_android_event_dispatch,
        NULL
    };

    GSource *source = g_source_new(&event_funcs, sizeof(GSource));
    g_source_set_name(source, "Android ALooper event source");
    g_source_set_priority(source, GDK_PRIORITY_EVENTS);
    g_source_set_can_recurse(source, TRUE);
    g_source_attach(source, NULL);
}
Ejemplo n.º 21
0
static void
clutter_master_clock_init (ClutterMasterClock *self)
{
  GSource *source;

  source = clutter_clock_source_new (self);
  self->source = source;

  self->idle = FALSE;
  self->ensure_next_iteration = FALSE;

  g_source_set_priority (source, CLUTTER_PRIORITY_REDRAW);
  g_source_set_can_recurse (source, FALSE);
  g_source_attach (source, NULL);
}
Ejemplo n.º 22
0
static void
setup_main_context (GdaConnection *cnc, guint *ptr_to_incr)
{
	GMainContext *context;
	GSource *idle;

	context = g_main_context_new ();
	idle = g_idle_source_new ();
	g_source_set_priority (idle, G_PRIORITY_DEFAULT);
	g_source_attach (idle, context);
	g_source_set_callback (idle, (GSourceFunc) idle_incr, ptr_to_incr, NULL);
	g_source_unref (idle);
	gda_connection_set_main_context (cnc, context);
	g_main_context_unref (context);	
}
Ejemplo n.º 23
0
RunLoop::TimerBase::TimerBase(RunLoop& runLoop)
    : m_runLoop(runLoop)
    , m_source(adoptGRef(g_source_new(&runLoopSourceFunctions, sizeof(GSource))))
{
    g_source_set_name(m_source.get(), "[WebKit] RunLoop::Timer work");
    g_source_set_callback(m_source.get(), [](gpointer userData) -> gboolean {
        RunLoop::TimerBase* timer = static_cast<RunLoop::TimerBase*>(userData);
        timer->fired();
        if (timer->m_isRepeating)
            timer->updateReadyTime();
        return G_SOURCE_CONTINUE;
    }, this, nullptr);
    g_source_set_priority(m_source.get(), G_PRIORITY_HIGH + 30);
    g_source_attach(m_source.get(), m_runLoop.m_mainContext.get());
}
Ejemplo n.º 24
0
void GSourceWrap::OneShot::construct(const char* name, std::function<void ()>&& function, std::chrono::microseconds delay, int priority, GMainContext* context)
{
    GRefPtr<GSource> source = adoptGRef(g_source_new(&sourceFunctions, sizeof(GSource)));

    g_source_set_name(source.get(), name);
    g_source_set_priority(source.get(), priority);

    g_source_set_callback(source.get(), static_cast<GSourceFunc>(staticOneShotCallback),
        new CallbackContext{ WTF::move(function), nullptr }, static_cast<GDestroyNotify>(destroyCallbackContext<CallbackContext>));
    g_source_set_ready_time(source.get(), targetTimeForDelay(delay));

    if (!context)
        context = g_main_context_get_thread_default();
    g_source_attach(source.get(), context);
}
Ejemplo n.º 25
0
/*
 *	Add an Trigger to the gmainloop world...
 */
GTRIGSource*
G_main_add_TriggerHandler(int priority,
			 gboolean (*dispatch)(gpointer user_data),
			 gpointer userdata, GDestroyNotify notify)
{
	GTRIGSource* trig_src = NULL;
	GSource * source = g_source_new(&G_TRIG_SourceFuncs, sizeof(GTRIGSource));
	gboolean failed = FALSE;
	
	trig_src = (GTRIGSource*)source;
	
	trig_src->magno		= MAG_GTRIGSOURCE;
	trig_src->maxdispatchdelayms = DEFAULT_MAXDELAY;
	trig_src->maxdispatchms	= DEFAULT_MAXDISPATCH;
	trig_src->dispatch	= dispatch;
	trig_src->udata		= userdata;
	trig_src->dnotify	= notify;
	lc_store((trig_src->detecttime), zero_longclock);

	trig_src->manual_trigger = FALSE;

	g_source_set_priority(source, priority);
	g_source_set_can_recurse(source, FALSE);

	if(!failed) {
		trig_src->gsourceid = g_source_attach(source, NULL);
		trig_src->description = "trigger";
		if (trig_src->gsourceid < 1) {
			cl_log(LOG_ERR, "G_main_add_TriggerHandler: Could not attach new source (%d)",
			       trig_src->gsourceid);
			failed = TRUE;
		}
	}
	
	if(failed) {
		cl_log(LOG_ERR, "G_main_add_TriggerHandler: Trigger handler NOT added");
		g_source_remove(trig_src->gsourceid);
		g_source_unref(source);
		source = NULL;
		trig_src = NULL;
	} else {
		if (debug_level > 1) {
			cl_log(LOG_DEBUG, "G_main_add_TriggerHandler: Added signal manual handler");
		}
	}
	
	return trig_src;
}
Ejemplo n.º 26
0
/**
 * g_io_scheduler_job_send_to_mainloop:
 * @job: a #GIOSchedulerJob
 * @func: a #GSourceFunc callback that will be called in the original thread
 * @user_data: data to pass to @func
 * @notify: a #GDestroyNotify for @user_data, or %NULL
 * 
 * Used from an I/O job to send a callback to be run in the thread
 * that the job was started from, waiting for the result (and thus
 * blocking the I/O job).
 *
 * Returns: The return value of @func
 **/
gboolean
g_io_scheduler_job_send_to_mainloop (GIOSchedulerJob *job,
				     GSourceFunc      func,
				     gpointer         user_data,
				     GDestroyNotify   notify)
{
  GSource *source;
  MainLoopProxy *proxy;
  gboolean ret_val;

  g_return_val_if_fail (job != NULL, FALSE);
  g_return_val_if_fail (func != NULL, FALSE);

  if (job->idle_tag)
    {
      /* We just immediately re-enter in the case of idles (non-threads)
       * Anything else would just deadlock. If you can't handle this, enable threads.
       */
      ret_val = func (user_data);
      if (notify)
	notify (user_data);
      return ret_val;
    }
  
  proxy = g_new0 (MainLoopProxy, 1);
  proxy->func = func;
  proxy->data = user_data;
  proxy->notify = notify;
  proxy->ack_lock = g_mutex_new ();
  proxy->ack_condition = g_cond_new ();
  g_mutex_lock (proxy->ack_lock);
  
  source = g_idle_source_new ();
  g_source_set_priority (source, G_PRIORITY_DEFAULT);
  g_source_set_callback (source, mainloop_proxy_func, proxy,
			 NULL);

  g_source_attach (source, job->context);
  g_source_unref (source);

  g_cond_wait (proxy->ack_condition, proxy->ack_lock);
  g_mutex_unlock (proxy->ack_lock);

  ret_val = proxy->ret_val;
  mainloop_proxy_free (proxy);
  
  return ret_val;
}
Ejemplo n.º 27
0
/* {{{ proto void \Glib\Source->setPriority(int priority)
        sets the priority of a source
   */
PHP_METHOD(GlibSource, setPriority)
{
	zend_long priority;
	gint set_priority;
	glib_source_object *source_object;

	if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "l", &priority) == FAILURE) {
		return;
	}

	source_object = Z_GLIB_SOURCE_P(getThis());
	GLIB_CHECK_INITIALIZED(source_object->source, Glib\\Source)
	set_priority = priority;

	g_source_set_priority(source_object->source, priority);
}
Ejemplo n.º 28
0
void GSourceWrap::DelayBased::initialize(const char* name, int priority, GMainContext* context)
{
    ASSERT(!m_source);
    m_source = adoptGRef(g_source_new(&sourceFunctions, sizeof(GSource)));

    m_context.delay = std::chrono::microseconds(0);
    m_context.cancellable = adoptGRef(g_cancellable_new());
    m_context.dispatching = false;

    g_source_set_name(m_source.get(), name);
    g_source_set_priority(m_source.get(), priority);

    if (!context)
        context = g_main_context_get_thread_default();
    g_source_attach(m_source.get(), context);
}
Ejemplo n.º 29
0
guint sock_add_watch_poll(SockInfo *sock, GIOCondition condition, SockFunc func,
			  gpointer data)
{
	GSource *source;

	sock->callback = func;
	sock->condition = condition;
	sock->data = data;

	source = g_source_new(&sock_watch_funcs, sizeof(SockSource));
	((SockSource *)source)->sock = sock;
	g_source_set_priority(source, G_PRIORITY_DEFAULT);
	g_source_set_can_recurse(source, FALSE);

	return g_source_attach(source, NULL);
}
Ejemplo n.º 30
0
void
frida_shutdown (void)
{
  GSource * source;

  g_assert (main_loop != NULL);

  source = g_idle_source_new ();
  g_source_set_priority (source, G_PRIORITY_LOW);
  g_source_set_callback (source, stop_main_loop, NULL, NULL);
  g_source_attach (source, main_context);
  g_source_unref (source);

  g_thread_join (main_thread);
  main_thread = NULL;
}