3

The boost::asio package contains classes for doing asynchronous file io in Windows using IO completion ports. To my understanding, there is no support for asynchronous file io for other platforms included in the asio package.

I am wondering what would need to be done in order to extend asio with asynchronous file io support for at least Mac OS X, but also to some extent Linux. I am mostly interested in what would need to be done on the asio side of things, but since I am not that experienced with Mac OS X programming I don't mind pointers on where to find more information on how to do asynchronous file io in Mac OS X as well - is PBReadForkAsync what I should be looking at?

Update: I've finally gotten around to attempt to build asynchronous file io (outside boost::asio) on Mac OS X using aio_read/aio_write, however I am unable to get the callback data I need (see How to get user data for aio signal handler in Mac OS X).

Community
  • 1
  • 1
villintehaspam
  • 8,540
  • 6
  • 45
  • 76

1 Answers1

2

According to this page, boost::asio works on OS X, with one minor constraint: http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio/overview/implementation.html

Andrew McGregor
  • 31,730
  • 2
  • 29
  • 28
  • 1
    Asio works under Mac OS X yes, however asynchronous file io is not available. According to the docs: Boost.Asio includes classes added to permit synchronous and asynchronous read and write operations to be performed on POSIX file descriptors, such as pipes, standard input and output, and various devices (but not regular files). ( http://www.boost.org/doc/libs/1_41_0/doc/html/boost_asio/overview/posix/stream_descriptor.html ). – villintehaspam Jan 14 '10 at 10:57
  • 1
    Updated the question to make it more clear that its only the file io part of the asio package that is "missing" for other platforms than Windows. – villintehaspam Jan 14 '10 at 11:18
  • 1
    Sorry, I missed that too. I think the better approach would be to treat OS X as a POSIX system, that way you get generic Unixen and Linux as well. See the `aio_read(2)` system call and `man aio`. And then maybe submit the class to Boost, because this really should be there. – Andrew McGregor Jan 14 '10 at 21:36
  • 1
    Unfortunately aio_read et al only support reporting completion using a signal on Mac OS X. Also, Mac OS X does not provide a means to send any user data to the signal handler so it is impossible to know exactly which operation completed. Because of this, it has been much easier for me to do synchronous io operations in a separate thread instead (as per my other question: http://stackoverflow.com/q/5116151/227322). – villintehaspam Mar 09 '11 at 11:38