Beatmup
recycle_bin.h
Go to the documentation of this file.
1
/*
2
Beatmup image and signal processing library
3
Copyright (C) 2019, lnstadrum
4
5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#pragma once
20
#include <mutex>
21
#include <vector>
22
#include "../context.h"
23
#include "../utils/lockable_object.h"
24
#include <initializer_list>
25
26
namespace
Beatmup
{
27
namespace
GL {
28
29
/**
30
Stores references to GPU resources that will not be used anymore and needed to be recycled in a thread having access to the GPU.
31
GPU resources such as texture handles generally cannot be destroyed in a user thread due to OpenGL API restrictions.
32
They are kept in a RecycleBin until the application empties it, which launches a task running in the thread that can access the GPU.
33
*/
34
class
RecycleBin
:
public
LockableObject
{
35
public
:
36
/**
37
A wrapper for a GPU resource. Destroyed in a GPU-aware thread when emptying the recycle bin.
38
*/
39
class
Item
{
40
private
:
41
Item
(
const
Item
&) =
delete
;
//!< disabling copying constructor
42
public
:
43
Item
() {}
44
virtual
~Item
() {}
45
};
46
47
private
:
48
std::vector<Item*>
items
;
49
Context
&
ctx
;
50
AbstractTask
*
recycler
;
51
52
public
:
53
RecycleBin
(
Context
&
ctx
);
54
~RecycleBin
();
55
56
/**
57
Puts an item into the recycle bin
58
*/
59
void
put
(
Item
* item);
60
61
/**
62
Puts items into the recycle bin
63
*/
64
void
put
(std::initializer_list<Item*>
items
);
65
66
/**
67
Empty the bin destroying all the items in a GPU-aware thread
68
*/
69
void
emptyBin
();
70
};
71
}
72
}
Beatmup::AbstractTask
Task: an operation that can be executed by multiple threads in parallel.
Definition:
parallelism.h:90
Beatmup::Context
Basic class: task and memory management, any kind of static data.
Definition:
context.h:59
Beatmup::GL::RecycleBin::Item
A wrapper for a GPU resource.
Definition:
recycle_bin.h:39
Beatmup::GL::RecycleBin::Item::Item
Item(const Item &)=delete
disabling copying constructor
Beatmup::GL::RecycleBin::Item::~Item
virtual ~Item()
Definition:
recycle_bin.h:44
Beatmup::GL::RecycleBin::Item::Item
Item()
Definition:
recycle_bin.h:43
Beatmup::GL::RecycleBin
Stores references to GPU resources that will not be used anymore and needed to be recycled in a threa...
Definition:
recycle_bin.h:34
Beatmup::GL::RecycleBin::put
void put(Item *item)
Puts an item into the recycle bin.
Definition:
recycle_bin.cpp:73
Beatmup::GL::RecycleBin::items
std::vector< Item * > items
Definition:
recycle_bin.h:48
Beatmup::GL::RecycleBin::~RecycleBin
~RecycleBin()
Definition:
recycle_bin.cpp:68
Beatmup::GL::RecycleBin::emptyBin
void emptyBin()
Empty the bin destroying all the items in a GPU-aware thread.
Definition:
recycle_bin.cpp:91
Beatmup::GL::RecycleBin::recycler
AbstractTask * recycler
Definition:
recycle_bin.h:50
Beatmup::GL::RecycleBin::ctx
Context & ctx
Definition:
recycle_bin.h:49
Beatmup::GL::RecycleBin::RecycleBin
RecycleBin(Context &ctx)
Definition:
recycle_bin.cpp:63
Beatmup::LockableObject
Definition:
lockable_object.h:24
Beatmup
Definition:
basic_types.h:22
core
gpu
recycle_bin.h
Generated on Tue Nov 21 2023 13:54:26 for Beatmup by
1.9.1