summaryrefslogtreecommitdiffstats
path: root/core/command_queue_mt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/command_queue_mt.cpp')
-rw-r--r--core/command_queue_mt.cpp36
1 files changed, 5 insertions, 31 deletions
diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp
index c20735939d..ace210ca2c 100644
--- a/core/command_queue_mt.cpp
+++ b/core/command_queue_mt.cpp
@@ -33,32 +33,24 @@
#include "core/os/os.h"
void CommandQueueMT::lock() {
-
- if (mutex)
- mutex->lock();
+ mutex.lock();
}
void CommandQueueMT::unlock() {
-
- if (mutex)
- mutex->unlock();
+ mutex.unlock();
}
void CommandQueueMT::wait_for_flush() {
-
// wait one millisecond for a flush to happen
OS::get_singleton()->delay_usec(1000);
}
CommandQueueMT::SyncSemaphore *CommandQueueMT::_alloc_sync_sem() {
-
int idx = -1;
while (true) {
-
lock();
for (int i = 0; i < SYNC_SEMAPHORES; i++) {
-
if (!sync_sems[i].in_use) {
sync_sems[i].in_use = true;
idx = i;
@@ -102,32 +94,14 @@ tryagain:
}
CommandQueueMT::CommandQueueMT(bool p_sync) {
-
- read_ptr = 0;
- write_ptr = 0;
- dealloc_ptr = 0;
- mutex = Mutex::create();
- command_mem = (uint8_t *)memalloc(COMMAND_MEM_SIZE);
-
- for (int i = 0; i < SYNC_SEMAPHORES; i++) {
-
- sync_sems[i].sem = Semaphore::create();
- sync_sems[i].in_use = false;
+ if (p_sync) {
+ sync = memnew(Semaphore);
}
- if (p_sync)
- sync = Semaphore::create();
- else
- sync = NULL;
}
CommandQueueMT::~CommandQueueMT() {
-
- if (sync)
+ if (sync) {
memdelete(sync);
- memdelete(mutex);
- for (int i = 0; i < SYNC_SEMAPHORES; i++) {
-
- memdelete(sync_sems[i].sem);
}
memfree(command_mem);
}