mirror of
https://github.com/TomHarte/CLK.git
synced 2024-07-17 13:29:02 +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)
|
void Shader::enqueue_function(std::function<void(void)> function)
|
||||||
{
|
{
|
||||||
|
_function_mutex.lock();
|
||||||
_enqueued_functions.push_back(function);
|
_enqueued_functions.push_back(function);
|
||||||
|
_function_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shader::flush_functions()
|
void Shader::flush_functions()
|
||||||
{
|
{
|
||||||
|
_function_mutex.lock();
|
||||||
for(std::function<void(void)> function : _enqueued_functions)
|
for(std::function<void(void)> function : _enqueued_functions)
|
||||||
{
|
{
|
||||||
function();
|
function();
|
||||||
}
|
}
|
||||||
_enqueued_functions.clear();
|
_enqueued_functions.clear();
|
||||||
|
_function_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
|
|
||||||
@ -110,6 +111,7 @@ private:
|
|||||||
|
|
||||||
void flush_functions();
|
void flush_functions();
|
||||||
std::list<std::function<void(void)>> _enqueued_functions;
|
std::list<std::function<void(void)>> _enqueued_functions;
|
||||||
|
std::mutex _function_mutex;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void enqueue_function(std::function<void(void)> function);
|
void enqueue_function(std::function<void(void)> function);
|
||||||
|
Loading…
Reference in New Issue
Block a user