Fixed thread init.

This commit is contained in:
Branimir Karadžić
2017-11-08 21:38:07 -08:00
parent ce5808f572
commit 9c7f2db06b
6 changed files with 94 additions and 25 deletions

View File

@@ -6,9 +6,13 @@
#include "test.h"
#include <bx/thread.h>
bx::MpScUnboundedBlockingQueue<void> s_mpsc;
int32_t threadExit0(bx::Thread* _thread, void*)
{
BX_UNUSED(_thread);
_thread->pop();
s_mpsc.push(reinterpret_cast<void*>(uintptr_t(0x1300) ) );
return bx::kExitSuccess;
}
@@ -17,10 +21,21 @@ int32_t threadExit1(bx::Thread* _thread, void*)
{
BX_UNUSED(_thread);
s_mpsc.push(reinterpret_cast<void*>(uintptr_t(0x89) ) );
return bx::kExitFailure;
}
TEST_CASE("thread", "")
TEST_CASE("Semaphore", "")
{
bx::Semaphore sem;
REQUIRE(!sem.wait(10) );
sem.post(1);
REQUIRE(sem.wait() );
}
TEST_CASE("Thread", "")
{
bx::Thread th;
@@ -28,6 +43,7 @@ TEST_CASE("thread", "")
th.init(threadExit0);
REQUIRE(th.isRunning() );
th.push(NULL);
th.shutdown();
REQUIRE(!th.isRunning() );
@@ -40,3 +56,13 @@ TEST_CASE("thread", "")
REQUIRE(!th.isRunning() );
REQUIRE(th.getExitCode() == 1);
}
TEST_CASE("MpScUnboundedBlockingQueue", "")
{
void* p0 = s_mpsc.pop();
void* p1 = s_mpsc.pop();
uintptr_t result = uintptr_t(p0) | uintptr_t(p1);
REQUIRE(result == 0x1389);
}