mirror of
https://github.com/thunderbrewhq/bc.git
synced 2025-12-12 01:52:30 +00:00
feat(process): add basic process functions
This commit is contained in:
parent
f9b65946a0
commit
3728c3d167
3 changed files with 39 additions and 0 deletions
15
bc/Process.cpp
Normal file
15
bc/Process.cpp
Normal 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
15
bc/Process.hpp
Normal 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
9
test/Process.cpp
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue