mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-05-25 22:14:34 +00:00
feat(kernel): enhance chrono and thread
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
parent
a1064d8978
commit
5d64c05446
@ -36,14 +36,15 @@ namespace std
|
||||
duration(const duration &) = default;
|
||||
|
||||
template <class Rep2>
|
||||
constexpr explicit duration(const Rep2 &r);
|
||||
constexpr explicit duration(const Rep2 &r) { rep_ = r; }
|
||||
|
||||
template <class Rep2, class Period2>
|
||||
constexpr duration(const duration<Rep2, Period2> &d);
|
||||
|
||||
duration &operator=(const duration &other) = default;
|
||||
|
||||
constexpr Rep count() const;
|
||||
constexpr Rep count() const { return rep_; }
|
||||
|
||||
static constexpr duration zero() noexcept;
|
||||
static constexpr duration min() noexcept;
|
||||
static constexpr duration max() noexcept;
|
||||
@ -115,5 +116,11 @@ namespace std
|
||||
using weeks = std::chrono::duration<int64_t, std::ratio<604800>>;
|
||||
using months = std::chrono::duration<int64_t, std::ratio<2629746>>;
|
||||
using years = std::chrono::duration<int64_t, std::ratio<31556952>>;
|
||||
|
||||
template <class ToDuration, class Rep, class Period>
|
||||
constexpr ToDuration duration_cast(const std::chrono::duration<Rep, Period> &d)
|
||||
{
|
||||
return ToDuration(d.count());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <task.hpp>
|
||||
#include <debug.h>
|
||||
#include <smp.hpp>
|
||||
#include <chrono>
|
||||
|
||||
extern Tasking::Task *TaskManager;
|
||||
|
||||
@ -32,6 +33,8 @@ namespace std
|
||||
Tasking::TCB *Task = nullptr;
|
||||
|
||||
public:
|
||||
using id = Tasking::TCB *;
|
||||
|
||||
thread() = default;
|
||||
thread(const thread &) = delete;
|
||||
thread(thread &&) = delete;
|
||||
@ -78,4 +81,20 @@ namespace std
|
||||
return Task;
|
||||
}
|
||||
};
|
||||
|
||||
namespace this_thread
|
||||
{
|
||||
thread::id get_id() noexcept;
|
||||
|
||||
void yield() noexcept;
|
||||
|
||||
template <class Clock, class Duration>
|
||||
void sleep_until(const chrono::time_point<Clock, Duration> &abs_time);
|
||||
|
||||
template <class Rep, class Period>
|
||||
void sleep_for(const chrono::duration<Rep, Period> &rel_time)
|
||||
{
|
||||
TaskManager->Sleep(chrono::duration_cast<std::chrono::milliseconds>(rel_time).count());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user