kodi
SharedMemory.h
1 /*
2  * Copyright (C) 2017-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "FileHandle.h"
12 #include "Mmap.h"
13 
14 #include <memory>
15 
16 namespace KODI
17 {
18 namespace UTILS
19 {
20 namespace POSIX
21 {
22 
30 {
31 public:
32  explicit CSharedMemory(std::size_t size);
33 
34  std::size_t Size() const
35  {
36  return m_size;
37  }
38  void* Data() const
39  {
40  return m_mmap.Data();
41  }
42  int Fd() const
43  {
44  return m_fd;
45  }
46 
47 private:
48  CSharedMemory(CSharedMemory const& other) = delete;
49  CSharedMemory& operator=(CSharedMemory const& other) = delete;
50 
51  CFileHandle Open();
52  CFileHandle OpenMemfd();
53  CFileHandle OpenShm();
54 
55  std::size_t m_size;
56  CFileHandle m_fd;
57  CMmap m_mmap;
58 };
59 
60 }
61 }
62 }
Get a chunk of shared memory of specified size.
Definition: SharedMemory.h:29
Definition: ColorUtils.h:18
Definition: FileHandle.h:22
Definition: AudioDecoder.h:18
Wrapper for mapped memory that automatically calls munmap on destruction.
Definition: Mmap.h:25