From 5e1d3c40efb06a2822db63d8005fae9b453fa1f0 Mon Sep 17 00:00:00 2001 From: otya128 Date: Sat, 3 Sep 2016 10:41:39 +0900 Subject: [PATCH] pthread --- SMILEBASIC/petitcomputer.d | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index b52ee8d..1e94d83 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -938,7 +938,12 @@ class PetitComputer glEnable(GL_ALPHA_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); xscreen(0, 512, 4); - renderCondition.notify(); + { + renderCondition.mutex.lock; + scope (exit) + renderCondition.mutex.unlock; + renderCondition.notify(); + } while(true) { auto profile = SDL_GetTicks(); @@ -1145,7 +1150,12 @@ class PetitComputer core.thread.Thread thread = new core.thread.Thread(&render); renderCondition = new Condition(new Mutex()); thread.start(); - renderCondition.wait(); + { + renderCondition.mutex.lock; + scope (exit) + renderCondition.mutex.unlock; + renderCondition.wait(); + } auto startTicks = SDL_GetTicks(); Parser parser; otya.smilebasic.vm.VM vm;