   Ideas for a Data Structure
  I'm making a server module for asynchronous I/O on data sources that only support synchronous I/O. I need it to be able to run multiple requests in multiple threads simultaneously. That's all easy enough; what I'm having trouble with is that I need it to only allow one operation per data source at one time. I'm not sure how to go about implementing this. The most obvious answer is a set; but this is impossible because the overhead of constantly allocating and freeing entries would be too high. Next I thought of a map that has a bool for each data source; but this also isn't a very good solution, because the entries will stay (and accumulate) even after the data sources are closed, gradually "leaking" memory. That leaves a vector of entries, one for each worker thread; but this seems pretty inefficient, as every worker thread that goes looking for a request to service will have to iterate over the list, checking each item against an array (something kinda like O(n^2)). Any ideas?   
  A set with a pooled allocator (such as boost::pool)?   