On May 25, 2015 6:26:48 PM EDT, Niall Douglas
On 25 May 2015 at 15:29, Rob Stewart wrote:
I would imagine destroying an open file handle would close it. Anyway, that really isn't important to the code examples given the topic, it was never mentioned what a handle_type is, I had an afio::async_io_handle in mind but it doesn't matter.
Your example calls ::open() and fd is an int.
Sorry, I must be missing something really obvious here.
I was assuming that handle_type consumes a valid fd and takes ownership of it. Are not the examples correct then, or if a particular example (of the four) is wrong, can you say which one?
The problem was in my inferences when reading the code. I wasn't thinking of the make_shared() expression as creating a handle_type from an implicit constructor taking an int when I read the examples. I saw, in effect, make_shared<int>(fd), with handle_type as a typedef for int. Since the reader isn't necessarily familiar with a class like your async_io_handle, it might be worth a sentence to indicate that handle_type takes ownership of the file descriptor to ensure people don't repeat my mistake. ___ Rob (Sent from my portable computation engine)