summaryrefslogtreecommitdiff
path: root/LibC/SharedBuffer.h
blob: 09c5b83f3ae1ab03260f3b5f34583ce5cf56354f (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
#pragma once

#include <AK/RetainPtr.h>
#include <AK/Retainable.h>

class SharedBuffer : public RefCounted<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;
};