By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,199 Members | 1,725 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,199 IT Pros & Developers. It's quick & easy.

Asking for recommendations on good generic asynchronous I/O library

P: n/a
Hello all, I'd like to ask recommendations about a "good" generic
asynchronous I/O library for C++. By generic I mean, something I can
use even on files, stdin/stdout, and sockets.

I've seen boost::asio, and also ioxxx, but most of the examples I've
seen with them are about sockets. Can they be used for general i/o
(files, terminal)? Can anyone point me to good tutorials about using
them for stuff other than sockets?

My use case is, I have a set of worker threads in a pool executing
tasks. Every now and then a task may need to perform I/O. If so, the
worker thread initiates the I/O and pushes the task back on the queue
and dequeues a new task. If a worker thread gets a task with pending
I/O, it checks if the I/O is complete, and if it isn't requeues it and
gets a new task, if the I/O is complete is continues with that task.

The reason I'd prefer to handle this case rather than just let the OS
block a thread is when, for some reason, I can only use one worker
thread (e.g. if threads are disabled, or the target doesn't have
threads, etc.). If so the only way I have to simulate multiple tasks
running in parallel would be to use asynchronous I/O on the single
worker thread. I'd rather have the same code to handle both the
single thread case and the multi-thread one, but if there are good
arguments against that I'll reconsider it.

Portability is good, but anything on Linux is OK for me ^^
Jul 7 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.