mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-27 06:35:04 +00:00
Made thread-safe.
This commit is contained in:
parent
091516e3cb
commit
00a2b42080
@ -291,14 +291,18 @@ void Shader::set_uniform_matrix(const std::string &name, GLint size, GLsizei cou
|
||||
|
||||
void Shader::enqueue_function(std::function<void(void)> function)
|
||||
{
|
||||
_function_mutex.lock();
|
||||
_enqueued_functions.push_back(function);
|
||||
_function_mutex.unlock();
|
||||
}
|
||||
|
||||
void Shader::flush_functions()
|
||||
{
|
||||
_function_mutex.lock();
|
||||
for(std::function<void(void)> function : _enqueued_functions)
|
||||
{
|
||||
function();
|
||||
}
|
||||
_enqueued_functions.clear();
|
||||
_function_mutex.unlock();
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
@ -110,6 +111,7 @@ private:
|
||||
|
||||
void flush_functions();
|
||||
std::list<std::function<void(void)>> _enqueued_functions;
|
||||
std::mutex _function_mutex;
|
||||
|
||||
protected:
|
||||
void enqueue_function(std::function<void(void)> function);
|
||||
|
Loading…
x
Reference in New Issue
Block a user