Re: Delay time to spawn new threads?



On Wed, Nov 27, 2013 at 11:20 AM, David Buchan <pdbuchan yahoo com> wrote:
Yes, I've tried the printf thing. It takes about 1.5 sec. Very strange.

It will be hard to help you much further without an example program.

If thread creation does in fact take so long on your platform, you can
perhaps create the thread ahead of time. What your thread should do is
just pop from a GAsyncQueue. This will cause the thread to block; then
when you push the button, you can use g_async_queue_push(), which will
wake the sleeping thread. This design has some side effects: when you
push the button twice, the work for the second button push will not
begin until the first button push work is finished. This may or may
not be an advantage.

Actually, instead of setting all that up yourself, you might want to
consider using a GThreadPool.

This is probably all overkill and there is some other problem unless
you are working on an some kind of embedded platform.


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