On 07/19/2015 08:00 AM, George Spelvin wrote:
> Hi,
> 
> I'm  new to libuv and I'd like to use libuv's work queue feature in a 
> project. Though I read, that uv_queue_work isn't thread safe and I'm unsure 
> what that exactly means. 
> 
> I'd like to use the libuv worker thread implementation from several different 
> threads, of course all of them with their own unique event loops. So 
> uv_work_queue() might be called in parallel by different threads. It's this 
> possible? Do I have to serialize probably parallel calls to uv_queue_work 
> (f.e. by mutexes)? Or do I have to implement the whole queue/thread pool 
> stuff in a thread safe manner by my own?
> 

Hi,

uv_queue_work must be called from a thread running an event loop. The
work callback will be called in a thread from the pool, but the after
work callback will be called in the loop thread.

Also note that you cannot call libuv functions such as uv_write from
within the work callback, because they are not thread safe.

Happy looping!


Cheers,

-- 
Saúl Ibarra Corretgé
bettercallsaghul.com


-- 
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to