mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Fixed thread init.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user