Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restricting thread_data to creating only with intrusive_pointers #1765

Merged
merged 3 commits into from Oct 1, 2015

Conversation

AntonBikineev
Copy link
Contributor

@hkaiser @K-ballo @sithhell What do you think of this sort of approach?

It seems to be close to the design where pool is a part of the thread_data model, but introduces some sort of dependency in intrusive_ptr_release with dynamic_cast..

memset (p, freed_value, sizeof(thread_data));
#endif
pool.deallocate(static_cast<thread_data*>(p));
if (thread_data* td = dynamic_cast<thread_data*>(p))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this dynamic_cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hkaiser: In current implementation thread_data_base can also refer to stackless_thread_data that doesn't use a pool for allocation scheme.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntonBikineev This operator delete() belongs to thread_data, not the base class. It shouldn't be called for a stackless_thread_data instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hkaiser sorry, Hartmut, don't get your point. This operator delete doesn't exist in this PR (I removed it). global delete is needed to be called for stackless_thread_data, as its object is allocated with global new here https://github.com/STEllAR-GROUP/hpx/blob/fixing_1763_2/hpx/runtime/threads/policies/thread_queue.hpp#L220

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh! my bad - I got confused by the diff. You're certainly right.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hkaiser, I guessed that diff might have confused you :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that dynamic_cast here. A virtual thread_pool *get_pool() { return 0; } in thread_data_base and a thread_pool *get_pool() { return pool_; } in thread_data would avoid this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sithhell don't like it either. I thought about the approach with get_pool. In this way is_created_from(pool*) also seems to be redundant. Another problem is that we have to check whether actual type is thread_data, not stackless_thread_data, because the latter doesn't actually use a pool for its creation/deletion.
Ideally, we should also think about the interface of these three classes and specify, do we need creation from pool be defined in thread_data_base?

@hkaiser
Copy link
Member

hkaiser commented Sep 28, 2015

I think we can remove the stackless_thread_data altogether. It is not used anywhere and was an experiment only in the first place.

@hkaiser
Copy link
Member

hkaiser commented Sep 30, 2015

LGTM now. Thanks!

sithhell added a commit that referenced this pull request Oct 1, 2015
Restricting thread_data to creating only with intrusive_pointers
@sithhell sithhell merged commit 38b5740 into master Oct 1, 2015
@sithhell sithhell deleted the fixing_1763_2 branch October 1, 2015 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants