Skip to content

Commit

Permalink
FIX set_photon_thread_stack_allocator implemention
Browse files Browse the repository at this point in the history
  • Loading branch information
Coldwings committed Jul 4, 2023
1 parent 32a7d38 commit 9783a9a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions thread/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,9 @@ R"(
if (unlikely(err))
LOG_ERROR_RETURN(err, -1, "Failed to allocate vcpu ", ERRNO(err));

if (!photon_thread_alloc || !photon_thread_dealloc)
set_photon_thread_stack_allocator();

auto th = *rq.pc = new thread;
th->vcpu = (vcpu_t*)ptr;
th->state = states::RUNNING;
Expand Down Expand Up @@ -1808,6 +1811,13 @@ R"(
return --_n_vcpu;
}

void set_photon_thread_stack_allocator(
Delegate<void *, size_t> _photon_thread_alloc,
Delegate<void, void *, size_t> _photon_thread_dealloc) {
photon_thread_alloc = _photon_thread_alloc;
photon_thread_dealloc = _photon_thread_dealloc;
}

void* stackful_malloc(size_t size) {
return CURRENT->stackful_malloc(size);
}
Expand Down

0 comments on commit 9783a9a

Please sign in to comment.