summaryrefslogtreecommitdiffhomepage
path: root/compat/shm.hpp
blob: 428764e42c392fbfcc399211e9472df65d05aedf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Copyright (c) 2013 Stanislaw Halik <sthalik@misaki.pl>

 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 */
#ifndef SHMXX_HEADER_GUARD
#define SHMXX_HEADER_GUARD

#include "export.hpp"
#include "shm.h"

#ifndef SHMXX_TYPE_NAME
#   define SHMXX_TYPE_NAME mem
#endif

class OTR_COMPAT_EXPORT SHMXX_TYPE_NAME final
{
    SHM_TYPE_NAME impl;

public:
    SHMXX_TYPE_NAME(const char* shm_name, const char* mutex_name, int map_size);
    ~SHMXX_TYPE_NAME();

    bool success() noexcept;
    void* ptr() noexcept;
    void lock() noexcept;
    void unlock() noexcept;

    SHMXX_TYPE_NAME& operator=(const SHMXX_TYPE_NAME&) = delete;
    SHMXX_TYPE_NAME& operator=(SHMXX_TYPE_NAME&&) noexcept;
};

#endif // SHMXX_HEADER_GUARD