adaptive_pool_test.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/interprocess for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #define BOOST_CONTAINER_ADAPTIVE_NODE_POOL_CHECK_INVARIANTS
  11. #include <boost/interprocess/detail/config_begin.hpp>
  12. #include <boost/interprocess/managed_shared_memory.hpp>
  13. #include <boost/interprocess/containers/list.hpp>
  14. #include <boost/interprocess/containers/vector.hpp>
  15. #include <boost/interprocess/allocators/adaptive_pool.hpp>
  16. #include "print_container.hpp"
  17. #include "dummy_test_allocator.hpp"
  18. #include "movable_int.hpp"
  19. #include "list_test.hpp"
  20. #include "vector_test.hpp"
  21. using namespace boost::interprocess;
  22. //We will work with wide characters for shared memory objects
  23. //Alias an adaptive pool that allocates ints
  24. typedef adaptive_pool
  25. <int, managed_shared_memory::segment_manager> shmem_node_allocator_t;
  26. typedef ipcdetail::adaptive_pool_v1
  27. <int, managed_shared_memory::segment_manager> shmem_node_allocator_v1_t;
  28. namespace boost {
  29. namespace interprocess {
  30. //Explicit instantiations to catch compilation errors
  31. template class adaptive_pool<int, managed_shared_memory::segment_manager>;
  32. template class adaptive_pool<void, managed_shared_memory::segment_manager>;
  33. namespace ipcdetail {
  34. template class ipcdetail::adaptive_pool_v1<int, managed_shared_memory::segment_manager>;
  35. template class ipcdetail::adaptive_pool_v1<void, managed_shared_memory::segment_manager>;
  36. }}}
  37. //Alias list types
  38. typedef list<int, shmem_node_allocator_t> MyShmList;
  39. typedef list<int, shmem_node_allocator_v1_t> MyShmListV1;
  40. //Alias vector types
  41. typedef vector<int, shmem_node_allocator_t> MyShmVector;
  42. typedef vector<int, shmem_node_allocator_v1_t> MyShmVectorV1;
  43. int main ()
  44. {
  45. if(test::list_test<managed_shared_memory, MyShmList, true>())
  46. return 1;
  47. if(test::list_test<managed_shared_memory, MyShmListV1, true>())
  48. return 1;
  49. if(test::vector_test<managed_shared_memory, MyShmVector>())
  50. return 1;
  51. if(test::vector_test<managed_shared_memory, MyShmVectorV1>())
  52. return 1;
  53. return 0;
  54. }
  55. #include <boost/interprocess/detail/config_end.hpp>