Guest User

Untitled

a guest
Feb 11th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. #include <CGAL/Simple_cartesian.h>
  2. #include <CGAL/Polyhedron_3.h>
  3.  
  4. #include <boost/interprocess/managed_shared_memory.hpp>
  5. #include <boost/interprocess/allocators/allocator.hpp>
  6.  
  7.  
  8.  
  9.  
  10. using namespace boost::interprocess;
  11.  
  12. typedef allocator<int, managed_shared_memory::segment_manager> ShMemAllocator;
  13.  
  14. managed_shared_memory segment(create_only,
  15. "MySharedMemory", //segment name
  16. 65536);
  17.  
  18. class blabla : public ShMemAllocator
  19. {
  20. public:
  21. blabla() : ShMemAllocator( segment.get_segment_manager() ){}
  22. };
  23.  
  24.  
  25. typedef CGAL::Simple_cartesian<double> Kernel;
  26.  
  27. typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_default, std::allocator<int> > PolyhedronStd;
  28.  
  29. typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_default, blabla > PolyhedronShMem;
  30.  
  31. //typedef allocator<int, managed_shared_memory::segment_manager> ShMemAllocator;
  32. //typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_default, ShMemAllocator > PolyhedronShMem;
  33.  
  34. int main(int argc, char** argv) {
  35.  
  36.  
  37. PolyhedronStd p; //ok
  38.  
  39. //Remove shared memory on construction and destruction
  40. struct shm_remove {
  41.  
  42. shm_remove() {
  43. shared_memory_object::remove("MySharedMemory");
  44. }
  45.  
  46. ~shm_remove() {
  47. shared_memory_object::remove("MySharedMemory");
  48. }
  49. } remover;
  50.  
  51. //Create shared memory
  52.  
  53.  
  54. //Create an allocator that allocates ints from the managed segment
  55. //allocator<int, managed_shared_memory::segment_manager>
  56. // allocator_instance(segment.get_segment_manager());
  57.  
  58.  
  59. PolyhedronShMem p2; //compilation error
  60.  
  61. //probably allocator_instance should be passed somehow to PolyhedronShMem but there is no way(?) to do it
  62. //PolyhedronShMem p3(allocator_instance); //unfortunatelly no such constructor
  63.  
  64. //PolyhedronShMem *p4 = segment.construct<PolyhedronShMem>("PolyhedronShMem")(allocator_instance);
  65.  
  66. return 0;
  67.  
  68. }
Add Comment
Please, Sign In to add comment