Re: GIOScheduler example need
- From: "Ardhan Madras" <ajhwb knac com>
- To: "Alexander Kuleshov" <kuleshovmail gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: GIOScheduler example need
- Date: Fri, 25 Jun 2010 00:08:45 -0700
    Hi, GIOSchedulerJob uses GThreadPool to run it's jobs if thread system is supported, otherwise it use 
g_idle_add*(), using GThreadPool maybe the best choice for handling some blocking operations such as I/O 
related call. Here an example for using GSchedulerJob. As you can see the main loop was not blocked although 
job_func call a blocking g_usleep().
#include <glib.h>
#include <gio/gio.h>
static gboolean source_func(void *data)
{
    g_print("im source\n");
    return TRUE;
}
static gboolean job_func(GIOSchedulerJob *job, GCancellable *cancellable, void *data)
{
    g_print ("im running\n");
    g_usleep(G_USEC_PER_SEC);
    return TRUE;
}
int main(void)
{
    GMainLoop *main_loop;
    g_thread_init(NULL);
    main_loop = g_main_loop_new(NULL, FALSE);
    g_io_scheduler_push_job(job_func, NULL, NULL, G_PRIORITY_DEFAULT, NULL);
    g_timeout_add(250, (GSourceFunc) source_func, NULL);
    g_main_loop_run(main_loop);
    return 0;
}
If GIOSchedulerJob documentation is not `clear', you can explore it's source at 
http://git.gnome.org/browse/glib/tree/gio/gioscheduler.c
The best documentations for programming is the code it's self right? ;p
                    Ardhan 
--- kuleshovmail gmail com wrote:
From: Alexander Kuleshov <kuleshovmail gmail com>
To: gtk-app-devel-list gnome org
Subject: GIOScheduler example need
Date: Thu, 24 Jun 2010 14:55:54 +0600
Hello,
I need to use GIOScheduler in my C/gtk+ application. Where can find
example of using GIOScheduler?
Thank you.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_____________________________________________________________
Listen to KNAC, Hit the Home page and Tune In Live! ---> http://www.knac.com
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]