asio pooled_list/hash_map implementation

I've been playing around with ways to remove some of the hits to the global allocator from asio/detail/reactor_op_queue.hpp, and decided to try an alternative approach to pooling. Instead of overriding STL allocators or global new/delete, I decided to implement pooled lists in terms of lists themselves. I take advantage of the fact that list::splice doesn't realloc nodes to move value data between the active and free lists during insert and erase operations. Chris's hash_map stores the value data in a std::list. I made that a template parameter, which allowed me to optionally specify the pooled_list. The implementation is here: http://baus.net/static/hash_map.hpp http://baus.net/static/pooled_list.hpp http://baus.net/static/pooled_hash_map.hpp This doesn't address the bigger problem of the handler allocation, but pre-allocing of the hash_map on *nix makes me a bit happier with the implementation. christopher

Hi Christopher, --- christopher baus <christopher@baus.net> wrote:
I've been playing around with ways to remove some of the hits to the global allocator from asio/detail/reactor_op_queue.hpp, and decided to try an alternative approach to pooling. <snip> This doesn't address the bigger problem of the handler allocation, but pre-allocing of the hash_map on *nix makes me a bit happier with the implementation.
Nice stuff. I'll try to integrate it soon. What I might also do is extend the list policy so that insert and erase operations take an allocation traits object. That way I can use the per-handler custom allocation for list nodes in the hash maps where entries are associated with operations, and your pooled hash map for everything else. Cheers, Chris
participants (2)
-
christopher baus
-
Christopher Kohlhoff