Skip to content

Commit

Permalink
🐛 resolved ambigous call to is_pow2 and fixed constness in async awai…
Browse files Browse the repository at this point in the history
…t helpers
  • Loading branch information
lamarrr committed Nov 28, 2024
1 parent d335be9 commit 26942ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ashura/std/async.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct Task
static_assert(TASK_ARENA_SIZE != 0,
"Task arena size must be a non-zero power of 2");

static_assert(is_pow2(TASK_ARENA_SIZE),
static_assert(is_pow2((u64) TASK_ARENA_SIZE),
"Task arena size must be a non-zero power of 2");

static_assert(TASK_ARENA_SIZE >= (MAX_TASK_FRAME_SIZE << 2),
Expand Down
18 changes: 9 additions & 9 deletions ashura/std/async.h
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,9 @@ inline Result<StopToken> create_stop_token(AllocatorImpl allocator)
/// @param any if to wait for all semaphores or atleast 1 semaphore.
/// @returns returns if the semaphore await operation completed successfully
/// based on the `any` criteria.
[[nodiscard]] inline bool
await_semaphores(Span<SemaphoreState const *const> sems,
Span<u64 const> stages, nanoseconds timeout)
[[nodiscard]] inline bool await_semaphores(Span<SemaphoreState *const> sems,
Span<u64 const> stages,
nanoseconds timeout)
{
CHECK(sems.size() == stages.size());
usize const n = sems.size();
Expand All @@ -558,9 +558,9 @@ inline Result<StopToken> create_stop_token(AllocatorImpl allocator)
{
for (; next < n; next++)
{
SemaphoreState const *const &s = sems[next];
u64 const stage = min(stages[next], s->num_stages_ - 1);
bool const is_ready = stage < s->stage();
SemaphoreState *const &s = sems[next];
u64 const stage = min(stages[next], s->num_stages_ - 1);
bool const is_ready = stage < s->stage();

if (!is_ready)
{
Expand Down Expand Up @@ -685,7 +685,7 @@ template <typename... T>
[[nodiscard]] bool await_streams(nanoseconds timeout, Span<u64 const> stages,
Stream<T> const &...streams)
{
SemaphoreState const *semaphores[] = {(streams.semaphore_.get())...};
SemaphoreState *semaphores[] = {(streams.semaphore_.get())...};

return await_semaphores(span(semaphores), stages, timeout);
}
Expand Down Expand Up @@ -752,8 +752,8 @@ template <typename... T>
[[nodiscard]] bool await_futures(nanoseconds timeout,
Future<T> const &...futures)
{
SemaphoreState const *semaphores[] = {(futures.stream_.semaphore_.get())...};
u64 const stages[] = {futures.stage_...};
SemaphoreState *semaphores[] = {(futures.stream_.semaphore_.get())...};
u64 const stages[] = {futures.stage_...};
return await_semaphores(span(semaphores), span(stages), timeout);
}

Expand Down

0 comments on commit 26942ff

Please sign in to comment.