/******************************************************************************** * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ #ifndef FAIR_MQ_SHMEM_UNMANAGEDREGION_H_ #define FAIR_MQ_SHMEM_UNMANAGEDREGION_H_ #include "Manager.h" #include #include #include #include #include // size_t #include namespace fair { namespace mq { namespace shmem { class Message; class Socket; class UnmanagedRegion final : public fair::mq::UnmanagedRegion { friend class Message; friend class Socket; public: UnmanagedRegion(Manager& manager, const size_t size, RegionCallback callback, const std::string& path = "", int flags = 0) : UnmanagedRegion(manager, size, 0, callback, path, flags) {} UnmanagedRegion(Manager& manager, const size_t size, const int64_t userFlags, RegionCallback callback, const std::string& path = "", int flags = 0) : fManager(manager) , fRegion(nullptr) , fRegionId(0) { auto result = fManager.CreateRegion(size, userFlags, callback, path, flags); fRegion = result.first; fRegionId = result.second; } void* GetData() const override { return fRegion->get_address(); } size_t GetSize() const override { return fRegion->get_size(); } ~UnmanagedRegion() override { fManager.RemoveRegion(fRegionId); } private: Manager& fManager; boost::interprocess::mapped_region* fRegion; uint64_t fRegionId; }; } } } #endif /* FAIR_MQ_SHMEM_UNMANAGEDREGION_H_ */