-------- Message original --------
Sujet: Re: Question concerning libubox and multithread
Date : Wed, 07 Nov 2012 15:22:54 +0100
De : Felix Fietkau <email@example.com>
Pour : KALLEL Mohamed <firstname.lastname@example.org>
Copie à : <email@example.com>, <firstname.lastname@example.org>
On 2012-11-07 2:59 PM, KALLEL Mohamed wrote:
I m contributing in the development of an opensource project which use
libubox. and I remarked that libubox execute handler functions in
monothread mode and not in muItithread mode.
1) so I m wondering if the libubox supports execution of handler in
multi thread mode ?
2) if yes how to activate multithread for registred handlers with libubox
3) if no. I m able to create 2 threads in my main program and then each
thread will call libubox functions to register handler function. Could
you give a quick how to do it with libubox?
uloop in libubox is currently not designed in a thread-safe way. I would
recommend running uloop in one thread only, and handing processing for
received events off to other threads. Would that be enough for the needs
of your application or do you need any specific changes?
I have not really looked at thread-safe use of epoll yet (which is used
in uloop internally), I only remember some recent kernel related
discussion pointing out that its threaded use may be a bit tricky
because of some race conditions that were only fixed recently.