Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <CGAL/Simple_cartesian.h>
- #include <CGAL/Polyhedron_3.h>
- #include <boost/interprocess/managed_shared_memory.hpp>
- #include <boost/interprocess/allocators/allocator.hpp>
- using namespace boost::interprocess;
- typedef allocator<int, managed_shared_memory::segment_manager> ShMemAllocator;
- managed_shared_memory segment(create_only,
- "MySharedMemory", //segment name
- 65536);
- class blabla : public ShMemAllocator
- {
- public:
- blabla() : ShMemAllocator( segment.get_segment_manager() ){}
- };
- typedef CGAL::Simple_cartesian<double> Kernel;
- typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_default, std::allocator<int> > PolyhedronStd;
- typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_default, blabla > PolyhedronShMem;
- //typedef allocator<int, managed_shared_memory::segment_manager> ShMemAllocator;
- //typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_default, ShMemAllocator > PolyhedronShMem;
- int main(int argc, char** argv) {
- PolyhedronStd p; //ok
- //Remove shared memory on construction and destruction
- struct shm_remove {
- shm_remove() {
- shared_memory_object::remove("MySharedMemory");
- }
- ~shm_remove() {
- shared_memory_object::remove("MySharedMemory");
- }
- } remover;
- //Create shared memory
- //Create an allocator that allocates ints from the managed segment
- //allocator<int, managed_shared_memory::segment_manager>
- // allocator_instance(segment.get_segment_manager());
- PolyhedronShMem p2; //compilation error
- //probably allocator_instance should be passed somehow to PolyhedronShMem but there is no way(?) to do it
- //PolyhedronShMem p3(allocator_instance); //unfortunatelly no such constructor
- //PolyhedronShMem *p4 = segment.construct<PolyhedronShMem>("PolyhedronShMem")(allocator_instance);
- return 0;
- }
Add Comment
Please, Sign In to add comment