3 #include "Arp/System/Core/TypeName.hxx"     4 #include "Arp/System/Core/AppDomainSingleton.hxx"     5 #include "Arp/System/Commons/Ipc/SharedMemory.hpp"     6 #include "Arp/System/Commons/Threading/Thread.hpp"     7 #include "boost/interprocess/containers/string.hpp"     8 #include "boost/interprocess/containers/vector.hpp"     9 #include "boost/interprocess/containers/list.hpp"    10 #include "boost/interprocess/containers/map.hpp"    11 #include "boost/interprocess/containers/set.hpp"    15 #ifdef ARP_PLATFORM_LINUX    19 namespace Arp { 
namespace System { 
namespace Commons { 
namespace Ipc
    25 template<
class Derived>
    29     typedef SharedMemory                                Base;
    30     typedef Derived                                     DerivedType;
    32     typedef boost::interprocess::managed_shared_memory  SharedMemory;
    33     typedef SharedMemory::segment_manager               SegmentManager;
    34     typedef boost::interprocess::permissions            SharedMemoryPermission;
    38     using Ptr = boost::interprocess::offset_ptr<T>;
    41     using ConstPtr = boost::interprocess::offset_ptr<const T>;
    50     static void    CreateInstance(
size_t memorySize);
    51     static void    OpenInstance(
void);
    52     static void    CloseInstance(
bool removeMemory = 
false);
    53     static void    Remove(
void);
    57     static void    WaitInstance(
const char* waitMessage, 
uint32 timeout = -1);
    65     class Allocator : 
public boost::interprocess::allocator<T, SegmentManager>
    68         typedef boost::interprocess::allocator<T, SegmentManager>    AllocatorBase;
    82 #ifdef ARP_PLATFORM_LINUX    88             pthread_mutexattr_t attr;
    89             pthread_mutexattr_init(&attr);
    91             pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_DEFAULT);
    92             pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
    93             pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT);
    95             pthread_mutex_init(&this->mutex, &attr);
    97             pthread_mutexattr_destroy(&attr);
   101             pthread_mutex_destroy(&this->mutex);
   107             pthread_mutex_lock(&this->mutex);
   111             pthread_mutex_unlock(&this->mutex);
   115         pthread_mutex_t mutex;
   121         Mutex(
void) = 
default;
   122         ~
Mutex(
void) = 
default;
   131             this->mutex.unlock();
   135         boost::interprocess::interprocess_mutex mutex;
   151     template <
class TMutex>
   157             this->pMutex->Lock();
   163                 this->pMutex->Unlock();
   173     typedef boost::interprocess::basic_string<char, std::char_traits<char>, 
Allocator<char>> String;
   176     using vector = boost::interprocess::vector<T, Allocator<T>>;
   179     using list = boost::interprocess::list<T, Allocator<T>>;
   181     template <
class TKey, 
class TValue, 
class TCompare = std::less<TKey>>
   182     using map = boost::interprocess::map<TKey, TValue, TCompare, Allocator<std::pair<const TKey, TValue>>>;
   184     template <
class TKey, 
class TCompare = std::less<TKey>>
   185     using set = boost::interprocess::set<TKey, TCompare, Allocator<TKey>>;
   188     template<
class T> 
friend class Allocator;
   193 template<
class Derived>
   199 template<
class Derived>
   205 template<
class Derived>
   212 template<
class Derived>
   219 template<
class Derived>
   227     bool instanceExists = 
false;
   233             instanceExists = 
true;
   237             Log::Debug(waitMessage);
   241     } 
while (!instanceExists);
   244 template<
class Derived>
   259 template<
class Derived>
   267 template<
class Derived>
 static Derived & CreateInstance(Args &&... args)
Creates this singleton instance.
Definition: AppDomainSingleton.hxx:74
 
This (meta programming) class provides the C++ typename of the as template argument passed type...
Definition: TypeName.hxx:55
 
Definition: SharedData.hxx:139
 
Definition: SharedData.hxx:26
 
std::uint32_t uint32
The Arp unsigned integer type of 4 byte size.
Definition: PrimitiveTypes.hpp:35
 
static void Sleep(size_t milliseconds)
Suspends the execution of the calling thread.
 
static Derived & GetInstance(void)
Gets a reference of the singleton instance.
Definition: AppDomainSingleton.hxx:102
 
Definition: SharedData.hxx:65
 
Definition: SharedData.hxx:75
 
Definition: SharedData.hxx:118
 
SharedMemoryImpl sharedMemoryImpl
Actual implementation of the shared memory functionality.
Definition: SharedMemory.hpp:142
 
Definition: SharedData.hxx:152
 
Root namespace for the PLCnext API
 
This class implements the singleton pattern for singletons with process wide scope.
Definition: AppDomainSingleton.hxx:24
 
static void DisposeInstance(void)
Disposes this singleton instance.
Definition: AppDomainSingleton.hxx:119
 
System components used by the System, Device, Plc or Io domains.
 
String GetSafeName(void) const
Gets a safe name of the as template parameter given type.
Definition: TypeName.hxx:144
 
static bool IsCreated(void)
Determines if this singleton instance is created yet.
Definition: AppDomainSingleton.hxx:91
 
const Arp::String & GetName(void) const
Returns the name of the memory object.
Definition: SharedMemory.hpp:157