-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
88 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// TODO Insert Allocator | ||
|
||
// TODO Insert singleton memory mananger -> Wird der überhaupt benötigt? | ||
// Vermutlich hauptsächlich um callbacks zu verwalten und die Synchronisierung zu machen | ||
#include <iostream> | ||
|
||
|
||
class buffer_recycler { | ||
public: | ||
template <class T> | ||
static void get(size_t number_elements) { | ||
if (!instance) | ||
instance = new buffer_recycler(); | ||
buffer_manager<T>::get(number_elements); | ||
} | ||
static void clean(void) { | ||
if (instance) | ||
delete instance; | ||
} | ||
private: | ||
static buffer_recycler *instance; | ||
buffer_recycler(void) { | ||
std::cout << "Buffer recycler constructor!" << std::endl; | ||
} | ||
~buffer_recycler(void) { | ||
std::cout << "Buffer recycler destructor!" << std::endl; | ||
} | ||
|
||
private: | ||
template<class T> | ||
class buffer_manager { | ||
public: | ||
static void get(size_t number_elements) { | ||
if (!instance) | ||
instance = new buffer_manager(); | ||
} | ||
|
||
private: | ||
std::list<T*> buffer_list; | ||
static buffer_manager<T> *instance; // requires C++17 | ||
|
||
buffer_manager(void) { | ||
std::cout << "Buffer mananger constructor for " << typeid(T).name() << std::endl; | ||
} | ||
~buffer_manager(void) { | ||
std::cout << "Buffer mananger destructor for " << typeid(T).name() << std::endl; | ||
} | ||
}; | ||
}; | ||
|
||
// Instance defintions | ||
buffer_recycler* buffer_recycler::instance = nullptr; | ||
|
||
template<class T> | ||
buffer_recycler::buffer_manager<T>* buffer_recycler::buffer_manager<T>::instance = nullptr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <hpx/hpx_main.hpp> // we don't need an hpx_main that way? | ||
#include <hpx/include/async.hpp> | ||
#include <hpx/include/lcos.hpp> | ||
|
||
#include "../include/buffer_manager.hpp" | ||
#include <cstdio> | ||
#include <typeinfo> | ||
|
||
|
||
// TODO Insert templated singleton submanager -> Eine Bufferliste pro Submanager. Ein Buffer is | ||
// Do it is as subclass | ||
|
||
// #pragma nv_exec_check_disable | ||
int main(int argc, char *argv[]) | ||
{ | ||
buffer_recycler::get<double>(1000); | ||
buffer_recycler::get<double>(1000); | ||
buffer_recycler::get<int>(1000); | ||
buffer_recycler::get<int>(1000); | ||
std::cout << std::endl; | ||
// Create Vectors with the new allocator | ||
|
||
buffer_recycler::clean(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters