Demo entry 6677109

a

   

Submitted by anonymous on Dec 02, 2017 at 06:04
Language: C++. Code size: 1.0 kB.

#ifndef Asegment_H
#define Asegment_H

#include <boost/interprocess/managed_mapped_file.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <functional>
#include <utility>
#include <string>

typedef boost::interprocess::managed_mapped_file mapped_file_t;
typedef boost::interprocess::managed_shared_memory shared_memory_t;

template <typename segment>
class Segment
{
public:
    typedef segment segment_t ;
    typedef typename segment_t::segment_manager segment_manager_t ;
public:
    Segment(const char * name, size_t size):
        name_(name),size_(size),
        segment_(boost::interprocess::open_or_create, name_.c_str(), size_ )
    { }

    segment_t & operator () ()
    {
        return segment_;
    }
private:
    std::string name_;
    size_t size_;
    segment_t segment_;
};

typedef Segment< mapped_file_t > MapedFile;
typedef Segment< shared_memory_t > SharedMemory;

#endif

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).