feat add marl for fiber
This commit is contained in:
@@ -38,7 +38,9 @@ private:
|
||||
template<typename T>
|
||||
class ThreadLocal final {
|
||||
public:
|
||||
ThreadLocal() : key_(detail::ThreadLocalManager::NextKey()) {}
|
||||
static_assert(std::is_pointer<T>::value, "T must be a pointer type");
|
||||
|
||||
inline ThreadLocal() : key_(detail::ThreadLocalManager::NextKey()) {}
|
||||
|
||||
~ThreadLocal()
|
||||
{ /*detail::ThreadLocalManager::Instance().Delete(key_); */
|
||||
|
||||
45
include/sled/system/fiber/fiber_scheduler.h
Normal file
45
include/sled/system/fiber/fiber_scheduler.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
#ifndef SLED_SYSTEM_FIBER_FIBER_SCHEDULER_H
|
||||
#define SLED_SYSTEM_FIBER_FIBER_SCHEDULER_H
|
||||
#include <marl/defer.h>
|
||||
#include <marl/scheduler.h>
|
||||
#include <marl/task.h>
|
||||
|
||||
namespace sled {
|
||||
using FiberScheduler = marl::Scheduler;
|
||||
|
||||
// schedule() schedules the task T to be asynchronously called using the
|
||||
// currently bound scheduler.
|
||||
inline void
|
||||
Schedule(marl::Task &&t)
|
||||
{
|
||||
MARL_ASSERT_HAS_BOUND_SCHEDULER("marl::schedule");
|
||||
auto scheduler = marl::Scheduler::get();
|
||||
scheduler->enqueue(std::move(t));
|
||||
}
|
||||
|
||||
// schedule() schedules the function f to be asynchronously called with the
|
||||
// given arguments using the currently bound scheduler.
|
||||
template<typename Function, typename... Args>
|
||||
inline void
|
||||
Schedule(Function &&f, Args &&...args)
|
||||
{
|
||||
MARL_ASSERT_HAS_BOUND_SCHEDULER("marl::schedule");
|
||||
auto scheduler = marl::Scheduler::get();
|
||||
scheduler->enqueue(marl::Task(
|
||||
std::bind(std::forward<Function>(f), std::forward<Args>(args)...)));
|
||||
}
|
||||
|
||||
// schedule() schedules the function f to be asynchronously called using the
|
||||
// currently bound scheduler.
|
||||
template<typename Function>
|
||||
inline void
|
||||
Schedule(Function &&f)
|
||||
{
|
||||
MARL_ASSERT_HAS_BOUND_SCHEDULER("marl::schedule");
|
||||
auto scheduler = marl::Scheduler::get();
|
||||
scheduler->enqueue(marl::Task(std::forward<Function>(f)));
|
||||
}
|
||||
}// namespace sled
|
||||
|
||||
#endif// SLED_SYSTEM_FIBER_FIBER_SCHEDULER_H
|
||||
10
include/sled/system/fiber/fiber_wait_group.h
Normal file
10
include/sled/system/fiber/fiber_wait_group.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#ifndef SLED_SYSTEM_FIBER_FIBER_WAIT_GROUP_H
|
||||
#define SLED_SYSTEM_FIBER_FIBER_WAIT_GROUP_H
|
||||
#include <marl/waitgroup.h>
|
||||
|
||||
namespace sled {
|
||||
using FiberWaitGroup = marl::WaitGroup;
|
||||
}
|
||||
|
||||
#endif// SLED_SYSTEM_FIBER_FIBER_WAIT_GROUP_H
|
||||
Reference in New Issue
Block a user