Re: glib branched

On Wed, 2012-10-03 at 08:20 +0200, David Nečas wrote:
> On Wed, Oct 03, 2012 at 12:35:57AM -0400, Matthias Clasen wrote:
> > I have now created a glib-2-34 branch, so master is now open for
> > ... GTask ...
> Is this also intended, at least in the future, for things like
> long-running calculations that need some monitoring/reporting of
> progress not just the final result?  I mean, some monitoring can be
> always implemented on top of GTask but once I get my hands dirty with
> explicit asynchronous communication I can implement that directly on top
> of GThread as well.  I always look hopefully at the asynchronous
> interfaces in GLib with hope, however, the intended use cases do not
> seem to match mine...

Popping results out of a running thread is easy to do.

Create a GAsyncQueue.
In your thread, add your results to the queue, a schedule a function to
be called from the main loop with g_idle_add().

In your g_idle_add() callback, use g_async_queue_pop() to get the
results, and free your results.

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