2018-05-25 18:21:59 +02:00
|
|
|
#include <coreinit/thread.h>
|
|
|
|
#include <coreinit/time.h>
|
|
|
|
#include <coreinit/systeminfo.h>
|
|
|
|
|
|
|
|
#include <whb/proc.h>
|
|
|
|
#include <whb/log.h>
|
|
|
|
#include <whb/log_console.h>
|
|
|
|
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
int
|
|
|
|
hello_thread()
|
|
|
|
{
|
2018-05-30 16:15:59 +02:00
|
|
|
int last_tm_sec = -1;
|
2018-05-25 18:21:59 +02:00
|
|
|
WHBLogPrintf("Hello World from a std::thread!");
|
|
|
|
|
|
|
|
while(WHBProcIsRunning()) {
|
2018-05-27 13:14:07 +02:00
|
|
|
OSCalendarTime tm;
|
2018-05-25 18:21:59 +02:00
|
|
|
OSTicksToCalendarTime(OSGetTime(), &tm);
|
2018-05-30 16:15:59 +02:00
|
|
|
|
|
|
|
if (tm.tm_sec != last_tm_sec) {
|
|
|
|
WHBLogPrintf("%02d/%02d/%04d %02d:%02d:%02d I'm still here.",
|
|
|
|
tm.tm_mday, tm.tm_mon, tm.tm_year,
|
|
|
|
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
|
|
last_tm_sec = tm.tm_sec;
|
|
|
|
}
|
2018-05-25 18:21:59 +02:00
|
|
|
|
|
|
|
WHBLogConsoleDraw();
|
2018-05-30 16:15:59 +02:00
|
|
|
OSSleepTicks(OSMillisecondsToTicks(100));
|
2018-05-25 18:21:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
WHBLogPrintf("Exiting... good bye.");
|
|
|
|
WHBLogConsoleDraw();
|
2018-05-28 12:39:36 +02:00
|
|
|
OSSleepTicks(OSMillisecondsToTicks(1000));
|
2018-05-25 18:21:59 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
2018-05-27 13:14:07 +02:00
|
|
|
WHBProcInit();
|
|
|
|
WHBLogConsoleInit();
|
|
|
|
|
2018-05-25 18:21:59 +02:00
|
|
|
std::thread t(hello_thread);
|
|
|
|
t.join();
|
2018-05-27 13:14:07 +02:00
|
|
|
|
|
|
|
WHBLogConsoleFree();
|
|
|
|
WHBProcShutdown();
|
2018-05-25 18:21:59 +02:00
|
|
|
return 0;
|
|
|
|
}
|