Skip to content
Closed
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
8 changes: 7 additions & 1 deletion core/thread/inc/ROOT/TThreadedObject.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,18 @@ namespace ROOT {
/// objects.
/// \tparam ARGS Arguments of the constructor of T
template<class ...ARGS>
TThreadedObject(ARGS&&... args): fObjPointers(fgMaxSlots, nullptr)
TThreadedObject(ARGS&&... args)
{
fDirectories = Internal::TThreadedObjectUtils::DirCreator<T>::Create(fgMaxSlots);

TDirectory::TContext ctxt(fDirectories[0]);
fModel.reset(Internal::TThreadedObjectUtils::Detacher<T>::Detach(new T(std::forward<ARGS>(args)...)));

if(ROOT::IsImplicitMTEnabled()) {
TThreadedObject<T>::fgMaxSlots = ROOT::GetImplicitMTPoolSize();
Copy link
Member

Choose a reason for hiding this comment

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

Why change the value for each TThreadObject creation?

Also, in order for this line (and the next) to be thread safe fgMaxSlots needs to be an std::atomic. [Otherwise, per the standard, the behavior when the reading (line 167) and the writing (line 164) happen at the 'same time' is undefined]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Will look into it 🤔

Copy link
Contributor

@eguiraud eguiraud Sep 20, 2017

Choose a reason for hiding this comment

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

@pcanal doesn't everything go bonkers anyway if users call EnableImplicitMT in a thread while they are using implicit-mt-aware features in other threads concurrently?

In other words, shouldn't EnableImplicitMT be called strictly before doing anything that checks whether implicit-mt is enabled or not?

}

fObjPointers.resize(fgMaxSlots, nullptr);
}

/// Access a particular processing slot. This
Expand Down