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

Rework incorrect assert in try_destroy_arena #781

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/tbb/market.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ market::market ( unsigned workers_soft_limit, unsigned workers_hard_limit, std::
__TBB_ASSERT( my_server, "Failed to create RML server" );
}

market::~market() {
poison_pointer(my_server);
poison_pointer(my_next_arena);
}

static unsigned calc_workers_soft_limit(unsigned workers_soft_limit, unsigned workers_hard_limit) {
if( int soft_limit = market::app_parallelism_limit() )
workers_soft_limit = soft_limit-1;
Expand Down Expand Up @@ -315,9 +320,8 @@ void market::detach_arena ( arena& a ) {
void market::try_destroy_arena ( arena* a, uintptr_t aba_epoch, unsigned priority_level ) {
bool locked = true;
__TBB_ASSERT( a, nullptr);
// we hold reference to the market, so it cannot be destroyed at any moment here
market::enforce([this] { return theMarket == this; }, nullptr);
__TBB_ASSERT( my_ref_count!=0, nullptr);
// we hold reference to the server, so market cannot be destroyed at any moment here
__TBB_ASSERT(!is_poisoned(my_server), nullptr);
my_arenas_list_mutex.lock();
arena_list_type::iterator it = my_arenas[priority_level].begin();
for ( ; it != my_arenas[priority_level].end(); ++it ) {
Expand Down
3 changes: 3 additions & 0 deletions src/tbb/market.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ class market : no_copy, rml::tbb_client {
//! Constructor
market ( unsigned workers_soft_limit, unsigned workers_hard_limit, std::size_t stack_size );

//! Destructor
~market();

//! Destroys and deallocates market object created by market::create()
void destroy ();

Expand Down