Re: libdispatch vs glib


Have you see my library iris[1]?

It includes a lot of the same sort of stuff (albeit not nearly the attention and optimization yet) and includes:

 * a work-stealing scheduler thats 8x faster than GThreadPool
   on my local machines (dual and quad-cores)
 * message-passing using ports/receivers
 * a dynamic scheduler manager that can scale threads as neaded
   and tear them back down.  applications can have multiple schedulers
   based on what they want if needed.
 * reusable lock-free data structures such as Queue, FreeList, Stack,
   and Round-Robin.
 * IrisTask which is like Twisted's Deferred for addCallback/addErrback
   type functionality.
 * iris_arbiter_coordinate() which is a reader/writer lock implemented
   asynchronously using message passing (on top of ports/receivers)
 * bindings for python, vala, and gobject-introspection (vala might be
   out of date though).
 * GMainLoop integration for scheduling callbacks in the mainloop.

One major thing it lacks

 * eyes looking at the code
 * documentation

But best of all, its written fully using GLib :-)

I wrote this during my spring/summer after I quit my job. However I start a new one in a few weeks but would love some input from others and ideally more people to commit features and generally use it.


-- Christian


cee1 wrote:
Hi all,
Following is a comparison between libdispatch and glib, just for interest.

First, libdispatch is the user space part of apple's GDC(Grand Central
Dispatch), resides at There is also
an introduction at

At first glimpse, libdispatch provides three different types of dispatch

   1. Main queue: equivalent of glib's main event loop
   2. Global queue: backed up by a thread pool. All the jobs sent to
      this queue, will be executed in arbitrary threads asynchronously.
   3. Private queue: jobs in this queue will be executed serially.

Both private queue and main queue are just threads in global queue. It
should be more user-friendly than combining GMainLoop and GThreadPool,
e.g. process GSource in another thread (i.e using thread pool in the
callback of that GSource).

The private queue can be considered as a pipeline (imaging GstPipeline
in gstreamer).

libdispatch also has a type of dispatch_source_t, equivalent of GSource,
but the callback is running in global queue, (hence, a different thread)

libdispatch is built on an extension to C (blocks), which is like GClosure.


gtk-devel-list mailing list
gtk-devel-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]