mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:57:45 +00:00
Add a C++ helper class for working with shared buffers.
This is a bit more comfortable than passing the shared buffer ID manually everywhere and keeping track of size etc.
This commit is contained in:
parent
0b5d5fc3c9
commit
eda0866992
14 changed files with 186 additions and 46 deletions
24
LibC/SharedBuffer.h
Normal file
24
LibC/SharedBuffer.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Retainable.h>
|
||||
#include <AK/RetainPtr.h>
|
||||
|
||||
class SharedBuffer : public Retainable<SharedBuffer> {
|
||||
public:
|
||||
static RetainPtr<SharedBuffer> create(pid_t peer, int);
|
||||
static RetainPtr<SharedBuffer> create_from_shared_buffer_id(int);
|
||||
~SharedBuffer();
|
||||
|
||||
int shared_buffer_id() const { return m_shared_buffer_id; }
|
||||
void seal();
|
||||
int size() const { return m_size; }
|
||||
void* data() { return m_data; }
|
||||
const void* data() const { return m_data; }
|
||||
|
||||
private:
|
||||
SharedBuffer(int shared_buffer_id, int size, void*);
|
||||
|
||||
int m_shared_buffer_id { -1 };
|
||||
int m_size { 0 };
|
||||
void* m_data;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue