Skip to content

Commit

Permalink
Merge pull request #75 from ikbuibui/invoke_result
Browse files Browse the repository at this point in the history
Small Fixes
  • Loading branch information
ikbuibui authored May 30, 2024
2 parents 8c53d8d + 5a3677b commit 7628d29
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 25 deletions.
1 change: 1 addition & 0 deletions redGrapes/memory/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace redGrapes

Block allocate(size_t n_bytes)
{
SPDLOG_TRACE("Allocate {} bytes on worker alloc [{}] ", n_bytes, worker_id);
return TaskFreeCtx::worker_alloc_pool.get_alloc(worker_id).allocate(n_bytes);
}

Expand Down
2 changes: 1 addition & 1 deletion redGrapes/memory/chunked_bump_alloc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <cstddef>

#if REDGRAPES_ENABLE_BACKWARDCPP
# include <backward.hpp"
# include <backward.hpp>
#endif

namespace redGrapes
Expand Down
12 changes: 6 additions & 6 deletions redGrapes/resource/resource_user.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ namespace redGrapes

template<typename TTask>
ResourceUser<TTask>::ResourceUser()
: scope_level(TaskCtx<TTask>::scope_depth())
, access_list(memory::Allocator())
: access_list(memory::Allocator())
, unique_resources(memory::Allocator())
, scope_level(TaskCtx<TTask>::scope_depth())
{
}

template<typename TTask>
ResourceUser<TTask>::ResourceUser(ResourceUser<TTask> const& other)
: scope_level(other.scope_level)
, access_list(memory::Allocator(), other.access_list)
: access_list(memory::Allocator(), other.access_list)
, unique_resources(memory::Allocator(), other.unique_resources)
, scope_level(other.scope_level)
{
}

template<typename TTask>
ResourceUser<TTask>::ResourceUser(std::initializer_list<ResourceAccess<TTask>> list)
: scope_level(TaskCtx<TTask>::scope_depth())
, access_list(memory::Allocator())
: access_list(memory::Allocator())
, unique_resources(memory::Allocator())
, scope_level(TaskCtx<TTask>::scope_depth())
{
for(auto& ra : list)
add_resource_access(ra);
Expand Down
8 changes: 4 additions & 4 deletions redGrapes/scheduler/event.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ namespace redGrapes
namespace scheduler
{
template<typename TTask>
Event<TTask>::Event() : state(1)
Event<TTask>::Event() : followers(memory::Allocator())
, waker_id(-1)
, followers(memory::Allocator())
, state(1)
{
}

template<typename TTask>
Event<TTask>::Event(Event& other)
: state((uint16_t) other.state)
: followers(memory::Allocator())
, waker_id(other.waker_id)
, followers(memory::Allocator())
, state((uint16_t) other.state)
{
}

Expand Down
4 changes: 2 additions & 2 deletions redGrapes/task/future.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ namespace redGrapes
template<typename T, typename TTask>
struct Future
{
Future(TTask& task) : task(task), taken(false)
Future(TTask& task) : taken(false), task(task)
{
}

Future(Future&& other) : task(other.task), taken(other.taken)
Future(Future&& other) : taken(other.taken), task(other.task)
{
SPDLOG_TRACE("MOVE future");
other.taken = true;
Expand Down
13 changes: 5 additions & 8 deletions redGrapes/task/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ namespace redGrapes
{

template<typename T>
concept C_TaskProperty = requires(T taskProp, typename T::Patch patch)
{
{
taskProp.apply_patch(patch)
} -> std::same_as<void>;
concept C_TaskProperty = requires(T taskProp, typename T::Patch patch) {
{ taskProp.apply_patch(patch) } -> std::same_as<void>;
};

template<C_TaskProperty... UserTaskProperties>
Expand Down Expand Up @@ -115,10 +112,10 @@ namespace redGrapes
};

template<typename F, typename TTask>
struct FunTask : ResultTask<typename std::result_of<F()>::type, TTask>
struct FunTask : ResultTask<typename std::invoke_result_t<F>, TTask>
{
FunTask(scheduler::IScheduler<TTask>& scheduler)
: ResultTask<typename std::result_of<F()>::type, TTask>(scheduler)
: ResultTask<typename std::invoke_result_t<F>, TTask>(scheduler)
{
}

Expand All @@ -128,7 +125,7 @@ namespace redGrapes
{
}

typename std::result_of<F()>::type run_result()
typename std::invoke_result_t<F> run_result()
{
return (*this->impl)();
}
Expand Down
4 changes: 2 additions & 2 deletions redGrapes/task/task_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ namespace redGrapes
template<typename TTask, typename Callable, typename... Args>
struct TaskBuilder : TTask::TaskProperties::template Builder<TaskBuilder<TTask, Callable, Args...>>
{
using Impl = typename std::result_of<BindArgs<Callable, Args...>(Callable, Args...)>::type;
using Result = typename std::result_of<Callable(Args...)>::type;
using Impl = typename std::invoke_result_t<BindArgs<Callable, Args...>, Callable, Args...>;
using Result = typename std::invoke_result_t<Callable, Args...>;

std::shared_ptr<TaskSpace<TTask>> space;
FunTask<Impl, TTask>* task;
Expand Down
4 changes: 2 additions & 2 deletions redGrapes/util/chunked_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ namespace redGrapes

Item()
// any item starts uninitialized
: iter_offset(1)
: storage(TrivialInit_t{})
, iter_offset(1)
, refcount(0)
, storage(TrivialInit_t{})
{
}

Expand Down

0 comments on commit 7628d29

Please sign in to comment.