-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/14/2014 09:50 PM, Iñaki Baz Castillo wrote:
> 2014-05-14 21:44 GMT+02:00 Saúl Ibarra Corretgé
> <[email protected]>:
>> You need to store your buffers in a queue from your worker thread
>> and then process the queue in the callback called after
>> uv_async_send.
>> 
>> Since you are appending to the queue from one thread and
>> processing it from another, it needs to be thread-safe.
> 
> 
> Which means locking a mutex when writing into the queue and when 
> reading from it.
> 

Yes, so?

> Anyhow I don't think the uv_async could work here since you may
> call to it X times (as you said), receive just Y events in the
> reader thread, and forget data in the queue (maybe, not sure).
> 

In a nutshell, an uv_async_send could be used just fine, but just for
the purpose of waking up the event loop. Then a uv_check_t handle
could be used to process the queue on each loop iteration.

There many ways to do it, I haven't thought of and/or implemented all
of them to assert which one is best, this is just one.

ConcurrencyKit has some nice data structures, you may want to check it
out: http://concurrencykit.org/


Cheers,

- -- 
Saúl Ibarra Corretgé
bettercallsaghul.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Icedove - http://www.enigmail.net/

iQIcBAEBAgAGBQJTc9grAAoJEEEOVVOum8BZlfoP/3WX/n1sMgJiWU0uvrt+bRr/
ac2IonQqI9CUvV/ouatQn/7XmIkUqqrOwlSZHzB7yEEQ7KA2b3kXDU9OzYyhqkXa
R15cpjjKcSsdop/rth99IshHTccpDxKi9u+69sMEUIbCy9QPWhoptTJIEL+euwfb
3YNJBotWvhaF7/bfbk0n8TTQPdZrNPGCkwf0CWweYbS9nDHVyOZCSq1+GQy5i31+
vHJWj32BNvgq/OXHTIL8JpBO+UXm2RUoGlLMm4j61vqOpOaW0oQyBVImc2YtgqXN
7aT4AQoLyJDBDyQc+1RFFVen5x1XlGBS2QYFp1LAJGWaSSE9LbPtCXBZfTpDBomY
cW7ipLeG992beMCkuex9ziyAeCwbnqLU203vqgMNagM89hPO9KVUfJfPcbR1mmr6
9uYZf6DbN40WQh1HXvMPKjkA19VF4BpNyFAwChudCe1DXLTn8vvr8JFZGtbW/VvP
4Iz6/6GR2ESScXk5y4s5hwcx2QgUQfvGPkuB79bR1W0oHf374j1dzVwAnykfkXvZ
ZOW20Bch7m5ObZVN7GNkHkvuczhHOBPeXw6wvaSnzGCH4qiLED6s3SHEDhjAnOh/
GJ0OgVz+hxufBWXBnx1VtxX3dnDeEGZ9p9UBmwCdegv0w6uVxv5cekng8ptIyJhP
GHeq9wIRd38ifIOhH/x1
=H/VI
-----END PGP SIGNATURE-----

-- 
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.

Reply via email to