You've already forked pico-launcher
mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-01-09 16:28:48 -08:00
Initial commit
This commit is contained in:
33
common/ipc/ThreadIpcService.cpp
Normal file
33
common/ipc/ThreadIpcService.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "common.h"
|
||||
#include "ThreadIpcService.h"
|
||||
|
||||
void ThreadIpcService::ThreadMain()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
rtos_waitEvent(&_event, false, true);
|
||||
if (_messageValid)
|
||||
{
|
||||
_messageValid = false;
|
||||
HandleMessage(_message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ThreadIpcService::Start()
|
||||
{
|
||||
rtos_createEvent(&_event);
|
||||
rtos_createThread(&_thread, 5, [] (void* arg)
|
||||
{
|
||||
static_cast<ThreadIpcService*>(arg)->ThreadMain();
|
||||
}, this, _stack, _stackSize);
|
||||
rtos_wakeupThread(&_thread);
|
||||
IpcService::Start();
|
||||
}
|
||||
|
||||
void ThreadIpcService::OnMessageReceived(u32 data)
|
||||
{
|
||||
_message = data;
|
||||
_messageValid = true;
|
||||
rtos_signalEvent(&_event);
|
||||
}
|
||||
Reference in New Issue
Block a user