{"issue":{"created_at":"2011-11-28T02:05:57Z","state":"closed","updated_at":"2011-11-28T11:39:31Z","user":{"gravatar_id":"eb0f066fba69ae24fd346fa097f82d61","id":84792,"url":"https://api.github.com/users/shtylman","avatar_url":"https://secure.gravatar.com/avatar/eb0f066fba69ae24fd346fa097f82d61?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"shtylman"},"comments":1,"body":"Currently, when calling uv_queue_work you have to provide the uv_work_t object and then clean it up after you use it. This is very error prone. It would be nice to adopt libeio behavior here and just have the user provide the baton pointer. The library should handle the creation of the work_t and destruction of it.\r\n\r\nThoughts? I am happy to provide the patch if this is the way forward.","assignee":null,"labels":[],"id":2363348,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"number":261,"title":"uv_queue_work should manage its own request","closed_at":"2011-11-28T11:39:31Z","html_url":"https://github.com/joyent/libuv/issues/261","url":"https://api.github.com/repos/joyent/libuv/issues/261","milestone":null},"action":"created","comment":{"created_at":"2011-11-28T11:39:31Z","updated_at":"2011-11-28T11:39:31Z","user":{"gravatar_id":"3d43d9038ab645ecb2e3a1df2951d30a","id":275871,"url":"https://api.github.com/users/bnoordhuis","avatar_url":"https://secure.gravatar.com/avatar/3d43d9038ab645ecb2e3a1df2951d30a?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"bnoordhuis"},"body":"No, for two reasons:\r\n\r\n1. One of libuv's design goals is to do as little malloc'ing as possible. That's why the caller is responsible for and has ownership of the uv_work_t struct.\r\n\r\n2. The uv_work_t struct is embeddable and that makes it very convenient to look up the embedding struct in your callback with a container_of construct ([example](https://github.com/joyent/node/blob/216019b/src/node_crypto.cc#L4172)). It's also a much more robust technique than pointer indirection since there is no risk of dangling pointers.","id":2895803,"url":"https://api.github.com/repos/joyent/libuv/issues/comments/2895803"}}