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

On 03/13/2014 04:08 PM, booch wrote:
> Hi all,
> 
> Quick question to help me understand the threadpooling behavior.
> 
> In the worker threads to get the uv__work request QUEUE_DATA is
> used - in master threadpool.c:73
> 
> In the async callback to get back on the main thread uv__work_done
> uses container_of - in master threadpool.c:218
> 
> Does anyone know the rationale for the difference?
> 

They are actually equivalent. QUEUE_DATA is meant to be used when
dealing with QUEUE pointers, but their implementation is the same(-ish):

#define container_of(ptr, type, member) \
  ((type *) ((char *) (ptr) - offsetof(type, member)))

and

#define QUEUE_DATA(ptr, type, field)    \
  ((type *) ((char *) (ptr) - ((char *) &((type *) 0)->field)))

Actually, "offsetof(type, member)))" is the same as "((char *) &((type
*) 0)->field)))".


Cheers,

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

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

iQIcBAEBAgAGBQJTIdioAAoJEEEOVVOum8BZjrgQALoI7mvcYd/vJP5oSBIBnRP9
lwsQNR/x0iinKAk1V9qT4XyTJXpowtLhm3CYVX7b8OfSPiMJaMeKN6BbnsErTjqb
JSqpKp4IinadT5SN6fs3Ug2iBEAL1kqNqY78XJX9l6JeQ+cqEgey/F68CGCrfmr9
+4De+y3B4i+RIgIg88Z6GyfrSnTwwaYpr1LFBNX70CFgj+USQEy5QIefPGfQATMX
B5hSrCwXfqk84dIxzqW4UVXKQiVSjlO6u5LmfvDes7yaKHeRACt0ds8i/FVb0J+L
uwkUHJlHL4UdvF7M3mRtlTP3w91F/2sMMbesMfsWOGLNHu2+HSq3c5Nwa4yrGJj0
3Z1khRh7XII/W4SNNjIOAQtAjrqEsKua+ZNWGTzbrYzNFY5h6bSek5Dq2CMRkx+G
73iMso52qquLCrz9MKy9yGioAXCvPkXAFaxbSzc8E5pAdkCBtFT54qTWDRaru2Ns
GPX/fUnZgpcEcXZrX/A4cj34QDqZCx/f0+2I6AI8xo0iuf7LzOQPdmjqpUj481N8
+2hTDL5n8zFTEq8eUtloOsukwliA+A8hcakGKEgxl6x2u8lwA5o2qJW4TLQfl0uN
b/B/6dAwFRTVmwn3IrgkIq27pmn6Ksf9gTfsWfiMnu0zhYR8FtZjwN8679zoE5qs
UjPFTMvPNDHOmj7CCsEj
=Nx1O
-----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