Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use boost::intrusive_ptr for thread_id_type
This change gets rid of using boost::intrusive_ptr to refcount thread_data. The lifetime of thread_data is perfectly managed by the scheduling policy. That is, once a task terminates, it can be deleted/reused.
- Loading branch information
Thomas Heller
committed
Jan 17, 2018
1 parent
3a711a6
commit bc74956
Showing
29 changed files
with
392 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,6 +334,11 @@ namespace hpx { namespace threads { namespace policies | |
HPX_ASSERT(num_thread < queue_size); | ||
queues_[num_thread]->create_thread(data, id, initial_state, | ||
run_now, ec); | ||
|
||
if (id) | ||
{ | ||
HPX_ASSERT((*id)->get_scheduler_base() == this); | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
hkaiser
Member
|
||
} | ||
|
||
/// Return the next thread to be executed, return false if none is | ||
|
@@ -460,6 +465,8 @@ namespace hpx { namespace threads { namespace policies | |
if (std::size_t(-1) == num_thread) | ||
num_thread = curr_queue_++ % queues_.size(); | ||
|
||
HPX_ASSERT(thrd->get_scheduler_base() == this); | ||
|
||
HPX_ASSERT(num_thread < queues_.size()); | ||
queues_[num_thread]->schedule_thread(thrd); | ||
} | ||
|
@@ -471,13 +478,17 @@ namespace hpx { namespace threads { namespace policies | |
if (std::size_t(-1) == num_thread) | ||
num_thread = curr_queue_++ % queues_.size(); | ||
|
||
HPX_ASSERT(thrd->get_scheduler_base() == this); | ||
|
||
HPX_ASSERT(num_thread < queues_.size()); | ||
queues_[num_thread]->schedule_thread(thrd, true); | ||
} | ||
|
||
/// Destroy the passed thread as it has been terminated | ||
bool destroy_thread(threads::thread_data* thrd, std::int64_t& busy_count) | ||
{ | ||
HPX_ASSERT(thrd->get_scheduler_base() == this); | ||
|
||
for (std::size_t i = 0; i != queues_.size(); ++i) | ||
{ | ||
if (queues_[i]->destroy_thread(thrd, busy_count)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
1 comment
on commit bc74956
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I'd suggest wrapping the thread_id into a separate type with pointer semantics, at least to ensure proper (implicit) initialization.
Please remove commented code.