mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
b907608e46
This allows us to seal a buffer *before* anyone else has access to it (well, ok, the creating process still does, but you can't win them all). It also means that a SharedBuffer can be shared with multiple clients: all you need is to have access to it to share it on again.
25 lines
651 B
C++
25 lines
651 B
C++
#pragma once
|
|
|
|
#include <AK/RefPtr.h>
|
|
#include <AK/RefCounted.h>
|
|
|
|
class SharedBuffer : public RefCounted<SharedBuffer> {
|
|
public:
|
|
static RefPtr<SharedBuffer> create_with_size(int);
|
|
static RefPtr<SharedBuffer> create_from_shared_buffer_id(int);
|
|
~SharedBuffer();
|
|
|
|
bool share_with(pid_t);
|
|
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;
|
|
};
|