diff --git a/lib/pls/include/pls/internal/base/aligned_stack.h b/lib/pls/include/pls/internal/base/aligned_stack.h index c463232..7c16fec 100644 --- a/lib/pls/include/pls/internal/base/aligned_stack.h +++ b/lib/pls/include/pls/internal/base/aligned_stack.h @@ -32,13 +32,13 @@ namespace pls { template T* push(const T& object) { - // Copy-Construct into desired memory location - return new (push())T(object); + // Placement new into desired memory location + return new ((void*)push())T(object); } template - T* push() { - T* result = reinterpret_cast(head_); + void* push() { + void* result = reinterpret_cast(head_); // Move head to next aligned position after new object head_ = next_alignment(head_ + sizeof(T)); diff --git a/lib/pls/include/pls/internal/scheduling/thread_state.h b/lib/pls/include/pls/internal/scheduling/thread_state.h index 58dcc9b..042c8f8 100644 --- a/lib/pls/include/pls/internal/scheduling/thread_state.h +++ b/lib/pls/include/pls/internal/scheduling/thread_state.h @@ -32,23 +32,6 @@ namespace pls { current_task_{nullptr}, task_stack_{task_stack}, id_{id} {} - - thread_state(const thread_state& other): - scheduler_{other.scheduler_}, - root_task_{other.root_task_}, - current_task_{other.current_task_}, - task_stack_{other.task_stack_}, - id_{other.id_} {} - - thread_state& operator=(const thread_state& other) { - scheduler_ = other.scheduler_; - root_task_ = other.root_task_; - current_task_ = other.current_task_; - task_stack_ = other.task_stack_; - id_ = other.id_; - - return *this; - } }; } } diff --git a/lib/pls/src/internal/scheduling/scheduler.cpp b/lib/pls/src/internal/scheduling/scheduler.cpp index 2930e1e..dd06768 100644 --- a/lib/pls/src/internal/scheduling/scheduler.cpp +++ b/lib/pls/src/internal/scheduling/scheduler.cpp @@ -14,8 +14,9 @@ namespace pls { } for (unsigned int i = 0; i < num_threads_; i++) { - new(memory_->thread_state_for(i)) thread_state{this, memory_->task_stack_for(i), i}; - *memory_->thread_for(i) = base::start_thread(&worker_routine, memory_->thread_state_for(i)); + // Placement new is required, as the memory of `memory_` is not required to be initialized. + new((void*)memory_->thread_state_for(i)) thread_state{this, memory_->task_stack_for(i), i}; + new ((void*)memory_->thread_for(i))base::thread(&worker_routine, memory_->thread_state_for(i)); } }