View on GitHub

Vistle

Distributed Data-parallel Scientific Visualization in VR

shmdata.h
Go to the documentation of this file.
1#ifndef VISTLE_SHMDATA_H
2#define VISTLE_SHMDATA_H
3
4#include <atomic>
5#include <string>
6#include <cassert>
7
8#include "shmname.h"
9
10namespace vistle {
11
12struct ShmData {
13 enum ShmType {
17 };
18
19 explicit ShmData(ShmType t, const std::string &name = std::string()): name(name), m_refcount(0), shmtype(t) {}
20
21 ~ShmData() { assert(m_refcount == 0); }
22
23 int ref() const
24 {
25 assert(m_refcount >= 0);
26 return ++m_refcount;
27 }
28
29 int unref() const
30 {
31 assert(m_refcount > 0);
32 return --m_refcount;
33 }
34
35 int refcount() const
36 {
37 assert(m_refcount >= 0);
38 return m_refcount;
39 }
40
42 mutable std::atomic<int> m_refcount;
44};
45
46} // namespace vistle
47#endif
Definition: allobjects.cpp:30
Definition: shmdata.h:12
int unref() const
Definition: shmdata.h:29
const shm_name_t name
Definition: shmdata.h:41
int ref() const
Definition: shmdata.h:23
ShmType
Definition: shmdata.h:13
@ INVALID
Definition: shmdata.h:14
@ OBJECT
Definition: shmdata.h:15
@ ARRAY
Definition: shmdata.h:16
~ShmData()
Definition: shmdata.h:21
ShmData(ShmType t, const std::string &name=std::string())
Definition: shmdata.h:19
const ShmType shmtype
Definition: shmdata.h:43
int refcount() const
Definition: shmdata.h:35
std::atomic< int > m_refcount
Definition: shmdata.h:42
Definition: shmname.h:11