/******************************************************************************** * 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" * ********************************************************************************/ /** * Region.h * * @since 2016-04-08 * @author A. Rybalchenko */ #ifndef FAIR_MQ_SHMEM_REGION_H_ #define FAIR_MQ_SHMEM_REGION_H_ #include "Common.h" #include #include #include #include #include #include #include #include #include namespace fair { namespace mq { namespace shmem { class Manager; struct Region { Region(Manager& manager, uint64_t id, uint64_t size, bool remote, RegionCallback callback, RegionBulkCallback bulkCallback, const std::string& path, int flags); Region() = delete; Region(const Region&) = delete; Region(Region&&) = delete; void InitializeQueues(); void StartSendingAcks(); void SendAcks(); void StartReceivingAcks(); void ReceiveAcks(); void ReleaseBlock(const RegionBlock &); ~Region(); Manager& fManager; bool fRemote; bool fStop; std::string fName; std::string fQueueName; boost::interprocess::shared_memory_object fShmemObject; FILE* fFile; boost::interprocess::file_mapping fFileMapping; boost::interprocess::mapped_region fRegion; std::mutex fBlockMtx; std::condition_variable fBlockSendCV; std::vector fBlocksToFree; const std::size_t fAckBunchSize = 256; std::unique_ptr fQueue; std::thread fReceiveAcksWorker; std::thread fSendAcksWorker; RegionCallback fCallback; RegionBulkCallback fBulkCallback; }; } // namespace shmem } // namespace mq } // namespace fair #endif /* FAIR_MQ_SHMEM_REGION_H_ */