QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context) : mainContext(context) { #if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 32 if (qEnvironmentVariableIsEmpty("QT_NO_THREADED_GLIB")) { static QBasicMutex mutex; QMutexLocker locker(&mutex); if (!g_thread_supported()) g_thread_init(NULL); } #endif 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.store(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); }
void owl_select_init(void) { owl_timer_source = g_source_new(&owl_timer_funcs, sizeof(GSource)); g_source_attach(owl_timer_source, NULL); owl_io_dispatch_source = g_source_new(&owl_io_dispatch_funcs, sizeof(GSource)); g_source_attach(owl_io_dispatch_source, NULL); }
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(); } } // setup post event source postEventSource = reinterpret_cast<GPostEventSource *>(g_source_new(&postEventSourceFuncs, sizeof(GPostEventSource))); postEventSource->serialNumber = 1; 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); }
void register_service (int port) { int dnsfd; GSource *source; if (DNSServiceRegister (&g_sdref, 0, 0, NULL, "_xmms2._tcp", NULL, NULL, g_htons (port), 0, NULL, dns_callback, NULL) != kDNSServiceErr_NoError) { printf ("failed to register!\n"); exit (1); } dnsfd = DNSServiceRefSockFD (g_sdref); if (dnsfd == -1) { printf ("no fd!?\n"); exit (1); } pollfd = g_new0 (GPollFD, 1); pollfd->fd = dnsfd; pollfd->events = G_IO_IN | G_IO_HUP | G_IO_ERR; source = g_source_new (&dns_ipc_func, sizeof (GSource)); g_source_add_poll (source, pollfd); g_source_attach (source, NULL); }
/** * gb_frame_source_add: * @frames_per_sec: (in): Target frames per second. * @callback: (in) (scope notified): A #GSourceFunc to execute. * @user_data: (in): User data for @callback. * * Creates a new frame source that will execute when the timeout interval * for the source has elapsed. The timing will try to synchronize based * on the end time of the animation. * * Returns: A source id that can be removed with g_source_remove(). */ guint gb_frame_source_add (guint frames_per_sec, GSourceFunc callback, gpointer user_data) { GbFrameSource *fsource; GSource *source; guint ret; g_return_val_if_fail(frames_per_sec > 0, 0); g_return_val_if_fail(frames_per_sec < 120, 0); source = g_source_new(&source_funcs, sizeof(GbFrameSource)); fsource = (GbFrameSource *)source; fsource->fps = frames_per_sec; fsource->frame_count = 0; fsource->start_time = g_get_monotonic_time() / 1000; g_source_set_callback(source, callback, user_data, NULL); g_source_set_name(source, "GbFrameSource"); ret = g_source_attach(source, NULL); g_source_unref(source); return ret; }
static void cockpit_ssh_transport_constructed (GObject *object) { CockpitSshTransport *self = COCKPIT_SSH_TRANSPORT (object); CockpitSshData *data; static GSourceFuncs source_funcs = { cockpit_ssh_source_prepare, cockpit_ssh_source_check, cockpit_ssh_source_dispatch, NULL, }; G_OBJECT_CLASS (cockpit_ssh_transport_parent_class)->constructed (object); g_return_if_fail (self->data->creds != NULL); g_warn_if_fail (ssh_options_set (self->data->session, SSH_OPTIONS_USER, cockpit_creds_get_user (self->data->creds)) == 0); self->io = g_source_new (&source_funcs, sizeof (CockpitSshSource)); ((CockpitSshSource *)self->io)->transport = self; g_source_attach (self->io, self->data->context); /* Setup for connect thread */ self->connect_fd = ssh_get_fd (self->data->session); g_atomic_int_set (&self->connecting, 1); self->data->connecting = &self->connecting; data = self->data; self->data = NULL; self->connect_thread = g_thread_new ("ssh-transport-connect", cockpit_ssh_connect_thread, data); g_debug ("%s: constructed", self->logname); }
static int setup_pollfds(void) { size_t numfds; size_t i; struct fp_pollfd *fpfds; GSource *gsource = g_source_new(&sourcefuncs, sizeof(struct fdsource)); fdsource = (struct fdsource *) gsource; fdsource->pollfds = NULL; numfds = fp_get_pollfds(&fpfds); if (numfds < 0) { if (fpfds) free(fpfds); return (int) numfds; } else if (numfds > 0) { for (i = 0; i < numfds; i++) { struct fp_pollfd *fpfd = &fpfds[i]; pollfd_add(fpfd->fd, fpfd->events); } } free(fpfds); fp_set_pollfd_notifiers(pollfd_added_cb, pollfd_removed_cb); g_source_attach(gsource, NULL); return 0; }
static GSource * g_io_unix_create_watch (GIOChannel *channel, GIOCondition condition) { GIOUnixChannel *unix_channel = (GIOUnixChannel *)channel; GSource *source; GIOUnixWatch *watch; source = g_source_new (&g_io_watch_funcs, sizeof (GIOUnixWatch)); g_source_set_name (source, "GIOChannel (Unix)"); watch = (GIOUnixWatch *)source; watch->channel = channel; g_io_channel_ref (channel); watch->condition = condition; watch->pollfd.fd = unix_channel->fd; watch->pollfd.events = condition; g_source_add_poll (source, &watch->pollfd); return source; }
GSource * _g_fd_source_new_with_object (GObject *object, int fd, gushort events, GCancellable *cancellable) { GSource *source; FDSource *fd_source; source = g_source_new (&fd_source_funcs, sizeof (FDSource)); fd_source = (FDSource *)source; if (cancellable) fd_source->cancellable = g_object_ref (cancellable); if (object) fd_source->object = g_object_ref (object); fd_source->pollfd.fd = fd; fd_source->pollfd.events = events; g_source_add_poll (source, &fd_source->pollfd); if (cancellable) fd_source->cancelled_tag = g_signal_connect_data (cancellable, "cancelled", (GCallback)fd_source_cancelled_cb, NULL, NULL, 0); return source; }
LOCAL_SYMBOL MetaEventQueue* meta_event_queue_new (Display *display, MetaEventQueueFunc func, gpointer data) { GSource *source; MetaEventQueue *eq; source = g_source_new (&eq_funcs, sizeof (MetaEventQueue)); eq = (MetaEventQueue*) source; eq->connection_fd = ConnectionNumber (display); eq->poll_fd.fd = eq->connection_fd; eq->poll_fd.events = G_IO_IN; eq->events = g_queue_new (); eq->display = display; g_source_set_priority (source, G_PRIORITY_DEFAULT); g_source_add_poll (source, &eq->poll_fd); g_source_set_can_recurse (source, TRUE); g_source_set_callback (source, (GSourceFunc) func, data, NULL); g_source_attach (source, NULL); g_source_unref (source); return eq; }
GSource * _g_fd_source_new (int fd, gushort events, GCancellable *cancellable) { GSource *source; FDSource *fd_source; source = g_source_new (&fd_source_funcs, sizeof (FDSource)); fd_source = (FDSource *)source; if (cancellable) fd_source->cancellable = g_object_ref (cancellable); fd_source->pollfd.fd = fd; fd_source->pollfd.events = events; g_source_add_poll (source, &fd_source->pollfd); if (cancellable) fd_source->cancelled_tag = g_cancellable_connect (cancellable, (GCallback)fd_source_cancelled_cb, NULL, NULL); return source; }
GSource * _g_fd_source_new (int fd, gushort events, GCancellable *cancellable) { GSource *source; FDSource *fd_source; source = g_source_new (&fd_source_funcs, sizeof (FDSource)); fd_source = (FDSource *)source; fd_source->pollfd.fd = fd; fd_source->pollfd.events = events; g_source_add_poll (source, &fd_source->pollfd); if (cancellable) { GSource *cancellable_source = g_cancellable_source_new (cancellable); g_source_set_dummy_callback (cancellable_source); g_source_add_child_source (source, cancellable_source); g_source_unref (cancellable_source); } return source; }
std::unique_ptr<PlatformDisplayWayland> PlatformDisplayWayland::create() { struct wl_display* wlDisplay = wl_display_connect(nullptr); if (!wlDisplay) { WTFLogAlways("PlatformDisplayWayland initialization: failed to connect to the Wayland server socket. Check your WAYLAND_DISPLAY or WAYLAND_SOCKET environment variables."); return nullptr; } std::unique_ptr<PlatformDisplayWayland> display(new PlatformDisplayWayland(wlDisplay)); if (!display->isInitialized()) { WTFLogAlways("PlatformDisplayWayland initialization: failed to complete the initialization of the display."); return nullptr; } GSource* baseSource = g_source_new(&EventSource::sourceFuncs, sizeof(EventSource)); auto* source = reinterpret_cast<EventSource*>(baseSource); source->display = display->m_display; source->pfd.fd = wl_display_get_fd(display->m_display); source->pfd.events = G_IO_IN | G_IO_ERR | G_IO_HUP; source->pfd.revents = 0; g_source_add_poll(baseSource, &source->pfd); g_source_set_name(baseSource, "[WebKit] WaylandDisplay"); g_source_set_priority(baseSource, G_PRIORITY_HIGH + 30); g_source_set_can_recurse(baseSource, TRUE); g_source_attach(baseSource, g_main_context_get_thread_default()); return display; }
GSource * g_tls_connection_base_create_source (GTlsConnectionBase *tls, GIOCondition condition, GCancellable *cancellable) { GSource *source, *cancellable_source; GTlsConnectionBaseSource *tls_source; source = g_source_new (&tls_source_funcs, sizeof (GTlsConnectionBaseSource)); g_source_set_name (source, "GTlsConnectionBaseSource"); tls_source = (GTlsConnectionBaseSource *)source; tls_source->tls = g_object_ref (tls); tls_source->condition = condition; if (condition & G_IO_IN) tls_source->stream = G_OBJECT (tls->tls_istream); else if (condition & G_IO_OUT) tls_source->stream = G_OBJECT (tls->tls_ostream); tls_source->op_waiting = (gboolean) -1; tls_source->io_waiting = (gboolean) -1; tls_source_sync (tls_source); if (cancellable) { cancellable_source = g_cancellable_source_new (cancellable); g_source_set_dummy_callback (cancellable_source); g_source_add_child_source (source, cancellable_source); g_source_unref (cancellable_source); } return source; }
guint g_usignal_add_full (gint priority, gint8 usignal, GUSignalFunc function, gpointer data, GDestroyNotify destroy) { guint s = 128 + usignal; g_return_val_if_fail (function != NULL, 0); GSource *source = g_source_new (&usignal_funcs, sizeof (GUSignalSource)); GUSignalSource *usignal_source = (GUSignalSource *) source; usignal_source->index = s / 32; usignal_source->shift = s % 32; usignal_source->callback = function; usignal_source->data = data; /* g_source_set_callback (source, GSourceFunc func, gpointer data, GDestroyNotify notify); */ return g_source_attach (source, NULL); //return g_source_add (priority, TRUE, &usignal_funcs, usignal_data, data, destroy); }
GSource * _g_posix_signal_source_new (gint signum) { sigset_t sigset; gint fd; GSource *_source; _GPosixSignalSource *source; _source = NULL; sigemptyset (&sigset); sigaddset (&sigset, signum); if (sigprocmask (SIG_BLOCK, &sigset, NULL) == -1) g_assert_not_reached (); fd = signalfd (-1, &sigset, SFD_NONBLOCK | SFD_CLOEXEC); _source = g_source_new (&_g_posix_signal_source_funcs, sizeof (_GPosixSignalSource)); source = (_GPosixSignalSource *) _source; source->pollfd.fd = fd; source->pollfd.events = G_IO_IN; g_source_add_poll (_source, &source->pollfd); source->signum = signum; return _source; }
GSource *io_add_watch_poll(Chardev *chr, QIOChannel *ioc, IOCanReadHandler *fd_can_read, QIOChannelFunc fd_read, gpointer user_data, GMainContext *context) { IOWatchPoll *iwp; char *name; iwp = (IOWatchPoll *) g_source_new(&io_watch_poll_funcs, sizeof(IOWatchPoll)); iwp->fd_can_read = fd_can_read; iwp->opaque = user_data; iwp->ioc = ioc; iwp->fd_read = (GSourceFunc) fd_read; iwp->src = NULL; name = g_strdup_printf("chardev-iowatch-%s", chr->label); g_source_set_name((GSource *)iwp, name); g_free(name); g_source_attach(&iwp->parent, context); g_source_unref(&iwp->parent); return (GSource *)iwp; }
struct result_queue* result_queue_new(GMainContext* context, result_queue_handler_f handler, gpointer userdata) { struct result_queue *queue; g_return_val_if_fail(handler!=NULL, NULL); queue = (struct result_queue *) g_source_new(&source_functions, sizeof(struct result_queue)); queue->async_queue=g_async_queue_new(); queue->handler=handler; queue->main_context=context; queue->userdata=userdata; g_source_set_callback(SOURCE(queue), source_callback, NULL/*data*/, NULL/*notify*/); g_source_attach(SOURCE(queue), context); result_queue_counter++; return queue; }
static gboolean g_mdns_poll_add (GMDNS *mdns, GMDNSUserData *ud, DNSServiceRef client) { ud->fd = g_new0 (GPollFD, 1); ud->fd->fd = DNSServiceRefSockFD (client); ud->client = client; ud->mdns = mdns; if (ud->fd->fd == -1) { g_free (ud->fd); g_free (ud); return FALSE; } ud->fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR; ud->source = g_source_new (&g_mdns_poll_funcs, sizeof (GSource)); g_source_set_callback (ud->source, (GSourceFunc) g_mdns_source_dispatch, ud, NULL); g_source_add_poll (ud->source, ud->fd); g_source_attach (ud->source, NULL); return TRUE; }
GSource * _clutter_x11_event_source_new (ClutterBackendX11 *backend_x11) { ClutterEventSource *event_source; int connection_number; GSource *source; gchar *name; connection_number = ConnectionNumber (backend_x11->xdpy); CLUTTER_NOTE (EVENT, "Connection number: %d", connection_number); source = g_source_new (&event_funcs, sizeof (ClutterEventSource)); event_source = (ClutterEventSource *) source; name = g_strdup_printf ("Clutter X11 Event (connection: %d)", connection_number); g_source_set_name (source, name); g_free (name); event_source->backend = backend_x11; event_source->event_poll_fd.fd = connection_number; event_source->event_poll_fd.events = G_IO_IN; g_source_add_poll (source, &event_source->event_poll_fd); g_source_set_can_recurse (source, TRUE); return source; }
/** * g_cancellable_source_new: (skip) * @cancellable: (allow-none): a #GCancellable, or %NULL * * Creates a source that triggers if @cancellable is cancelled and * calls its callback of type #GCancellableSourceFunc. This is * primarily useful for attaching to another (non-cancellable) source * with g_source_add_child_source() to add cancellability to it. * * For convenience, you can call this with a %NULL #GCancellable, * in which case the source will never trigger. * * Return value: (transfer full): the new #GSource. * * Since: 2.28 */ GSource * g_cancellable_source_new (GCancellable *cancellable) { GSource *source; GCancellableSource *cancellable_source; source = g_source_new (&cancellable_source_funcs, sizeof (GCancellableSource)); g_source_set_name (source, "GCancellable"); cancellable_source = (GCancellableSource *)source; if (cancellable) { cancellable_source->cancellable = g_object_ref (cancellable); /* We intentionally don't use g_cancellable_connect() here, * because we don't want the "at most once" behavior. */ cancellable_source->cancelled_handler = g_signal_connect (cancellable, "cancelled", G_CALLBACK (cancellable_source_cancelled), source); if (g_cancellable_is_cancelled (cancellable)) g_source_set_ready_time (source, 0); } return source; }
static GSource* createMicrosecondsTimeoutSource(uint64_t delay) { GSource* source = g_source_new(µsecondsTimeoutSourceFunctions, sizeof(MicrosecondsTimeoutSource)); reinterpret_cast<MicrosecondsTimeoutSource*>(source)->delay = delay; g_source_set_ready_time(source, g_get_monotonic_time() + delay); return source; }
static void string_job_init() { darktable.lua_state.string_job_queue = g_async_queue_new(); GSource *source = g_source_new (&string_job_funcs, sizeof (GSource)); g_source_set_name (source, "lua_string_job_source"); g_source_attach(source,darktable.lua_state.context); }
GSource * gdk_x11_event_source_new (GdkDisplay *display) { GSource *source; GdkEventSource *event_source; GdkX11Display *display_x11; int connection_number; char *name; source = g_source_new (&event_funcs, sizeof (GdkEventSource)); name = g_strdup_printf ("GDK X11 Event source (%s)", gdk_display_get_name (display)); g_source_set_name (source, name); g_free (name); event_source = (GdkEventSource *) source; event_source->display = display; display_x11 = GDK_X11_DISPLAY (display); connection_number = ConnectionNumber (display_x11->xdisplay); event_source->event_poll_fd.fd = connection_number; event_source->event_poll_fd.events = G_IO_IN; g_source_add_poll (source, &event_source->event_poll_fd); g_source_set_priority (source, GDK_PRIORITY_EVENTS); g_source_set_can_recurse (source, TRUE); g_source_attach (source, NULL); event_sources = g_list_prepend (event_sources, source); return source; }
/* * Create a event source object for connection. The object * will be added to "Event Context" for polling. */ __export HmWatch * hm_listen_watch_create(HmConnection *conn, HmWatchFuncs *funcs, gint size) { GSource *source; HmWatch *watch; G_ASSERT(conn != NULL && funcs != NULL && size >= sizeof(HmWatch)); source = g_source_new(&hm_watch_funcs, size); watch = (HmWatch*)source; watch->buffer = NULL; watch->lock = g_mutex_new(); watch->conn = conn; watch->funcs = funcs; watch->r_fd.fd = hm_connection_get_fd(conn); watch->r_fd.events = READ_COND; watch->r_fd.revents = 0; hm_watch_init_time(watch); watch->w_pending = 0; watch->killed = 0; watch->heavy_io_load = hm_connection_is_heavy(conn); watch->block_size = hm_connection_get_buffer_size(conn); hm_watch_set_callback(watch, hm_watch_listen_dispatch, NULL); g_source_add_poll(source, &watch->r_fd); g_atomic_int_add(&total_watch_count, 1); return watch; }
static void _gck_call_base_init (GckCallClass *klass) { GckCallSource *source; GMainContext *context; GError *err = NULL; klass->thread_pool = g_thread_pool_new ((GFunc)process_async_call, klass, 16, FALSE, &err); if (!klass->thread_pool) { g_critical ("couldn't create thread pool: %s", err && err->message ? err->message : ""); return; } klass->completed_queue = g_async_queue_new_full (g_object_unref); g_assert (klass->completed_queue); context = g_main_context_default (); g_assert (context); /* Add our idle handler which processes other tasks */ source = (GckCallSource*)g_source_new (&completed_functions, sizeof (GckCallSource)); source->klass = klass; klass->completed_id = g_source_attach ((GSource*)source, context); g_source_set_callback ((GSource*)source, NULL, NULL, NULL); g_source_unref ((GSource*)source); }
gboolean xevent_init() { X11Source* xsource; int fd; dpy = XOpenDisplay( g_getenv("DISPLAY") ); if( ! dpy ) return FALSE; /* according to the spec, private Atoms should prefix their names with _. */ CMD_ATOM = XInternAtom( dpy, "_LXSESSION", False ); fd = ConnectionNumber(dpy); /* fd of XDisplay connection */ if( G_UNLIKELY(fd == -1) ) return FALSE; /* set up main loop event source for XDisplay */ source = g_source_new (&event_funcs, sizeof(X11Source)); xsource = (X11Source*)source; xsource->poll_fd.fd = fd; xsource->poll_fd.events = G_IO_IN; g_source_add_poll(source, &xsource->poll_fd); g_source_set_can_recurse(source, TRUE); g_source_attach(source, NULL); return TRUE; }
ViewBackend::ViewBackend(struct wpe_view_backend* backend) : backend(backend) { ipcHost.initialize(*this); bcm_host_init(); displayHandle = vc_dispmanx_display_open(0); graphics_get_display_size(DISPMANX_ID_HDMI, &width, &height); updateFd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); if (updateFd == -1) { fprintf(stderr, "ViewBackend: failed to create the update eventfd\n"); return; } updateSource = g_source_new(&UpdateSource::sourceFuncs, sizeof(UpdateSource)); auto& source = *reinterpret_cast<UpdateSource*>(updateSource); source.backend = this; source.pfd.fd = updateFd; source.pfd.events = G_IO_IN | G_IO_ERR | G_IO_HUP; source.pfd.revents = 0; g_source_add_poll(updateSource, &source.pfd); g_source_set_name(updateSource, "[WPE] BCMRPi update"); g_source_set_priority(updateSource, G_PRIORITY_HIGH + 30); g_source_set_can_recurse(updateSource, TRUE); g_source_attach(updateSource, g_main_context_get_thread_default()); }
GSource * _gdk_wayland_display_event_source_new (GdkDisplay *display) { GSource *source; GdkWaylandEventSource *wl_source; GdkWaylandDisplay *display_wayland; char *name; source = g_source_new (&wl_glib_source_funcs, sizeof (GdkWaylandEventSource)); name = g_strdup_printf ("GDK Wayland Event source (%s)", "display name"); g_source_set_name (source, name); g_free (name); wl_source = (GdkWaylandEventSource *) source; display_wayland = GDK_WAYLAND_DISPLAY (display); wl_source->display = display; wl_source->pfd.fd = wl_display_get_fd(display_wayland->wl_display); wl_source->pfd.events = G_IO_IN | G_IO_ERR | G_IO_HUP; g_source_add_poll(source, &wl_source->pfd); g_source_set_priority (source, GDK_PRIORITY_EVENTS); g_source_set_can_recurse (source, TRUE); g_source_attach (source, NULL); event_sources = g_list_prepend (event_sources, source); return source; }
void glibcurl_init() { int fd; /* Create source object for curl file descriptors, and hook it into the default main context. */ curlSrc = (CurlGSource*)g_source_new(&curlFuncs, sizeof(CurlGSource)); g_source_attach(&curlSrc->source, NULL); /* Init rest of our data */ memset(&curlSrc->lastPollFd, 0, sizeof(curlSrc->lastPollFd)); for (fd = 1; fd <= GLIBCURL_FDMAX; ++fd) curlSrc->lastPollFd[fd].fd = fd; curlSrc->lastPollFdMax = 0; curlSrc->callPerform = 0; /* Init libcurl */ curl_global_init(CURL_GLOBAL_ALL); curlSrc->multiHandle = curl_multi_init(); curl_multi_setopt(curlSrc->multiHandle, CURLMOPT_MAXCONNECTS, 4); g_source_set_priority((GSource*)glibcurl_handle(), G_PRIORITY_DEFAULT_IDLE); D((stderr, "events: R=%x W=%x X=%x\n", GLIBCURL_READ, GLIBCURL_WRITE, GLIBCURL_EXC)); s_numEasyHandles = 0; s_currTimeout = 0; s_timeAtLastDispatch.tv_sec = 0; s_timeAtLastDispatch.tv_nsec = 0; }