feat(process): add basic process functions

This commit is contained in:
fallenoak 2023-03-03 10:44:30 -06:00 committed by GitHub
parent f9b65946a0
commit 3728c3d167
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 0 deletions

15
bc/Process.cpp Normal file
View file

@ -0,0 +1,15 @@
#include "bc/Process.hpp"
#include <ctime>
void Blizzard::Process::Sleep(uint32_t duration) {
#if defined(WHOA_SYSTEM_WIN)
// TODO
#elif defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
struct timespec request;
request.tv_sec = 0;
request.tv_nsec = duration * 1000000;
nanosleep(&request, nullptr);
#endif
}

15
bc/Process.hpp Normal file
View file

@ -0,0 +1,15 @@
#ifndef BC_PROCESS_HPP
#define BC_PROCESS_HPP
#include <cstdint>
namespace Blizzard {
namespace Process {
// Functions
void Sleep(uint32_t duration);
} // namespace Process
} // namespace Blizzard
#endif

9
test/Process.cpp Normal file
View file

@ -0,0 +1,9 @@
#include "bc/Process.hpp"
#include "test/Test.hpp"
TEST_CASE("Blizzard::Process::Sleep", "[process]") {
SECTION("sleeps") {
Blizzard::Process::Sleep(1);
SUCCEED();
}
}