62#ifdef R__CHECK_COLLECTION_MULTI_ACCESS 
   64void TCollection::TErrorLock::ConflictReport(std::thread::id holder, 
const char *accesstype,
 
   65                                             const TCollection *collection, 
const char *function)
 
   68   auto local = std::this_thread::get_id();
 
   69   std::stringstream cur, loc;
 
   70   if (holder == std::thread::id())
 
   73      cur << 
"0x" << std::hex << holder;
 
   74   loc << 
"0x" << std::hex << local;
 
   82           "Access (%s) to a collection (%s:%p) from multiple threads at a time. holder=%s readers=%lu intruder=%s",
 
   83           accesstype, collection->IsA()->
GetName(), collection, cur.str().c_str(), fReadSet.size(), loc.str().c_str());
 
   85   std::set<std::thread::id> tmp;
 
   86   for (
auto r : fReadSet) tmp.insert(
r);
 
   88      std::stringstream reader;
 
   89      reader << 
"0x" << std::hex << 
r;
 
   90      ::Error(function, 
" Readers includes %s", reader.str().c_str());
 
   95void TCollection::TErrorLock::Lock(
const TCollection *collection, 
const char *function)
 
   97   auto local = std::this_thread::get_id();
 
   99   std::thread::id holder;
 
  101   if (fWriteCurrent.compare_exchange_strong(holder, local)) {
 
  103      ++fWriteCurrentRecurse;
 
  108      if (fReadCurrentRecurse) {
 
  109         if (fReadSet.size() > 1 || fReadSet.find(local) != fReadSet.end()) {
 
  110            ConflictReport(std::thread::id(), 
"WriteLock while ReadLock taken", collection, function);
 
  116      if (holder == local) {
 
  122         ConflictReport(holder, 
"WriteLock", collection, function);
 
  124      ++fWriteCurrentRecurse;
 
  128void TCollection::TErrorLock::Unlock()
 
  130   auto local = std::this_thread::get_id();
 
  131   auto none = std::thread::id();
 
  133   --fWriteCurrentRecurse;
 
  134   if (fWriteCurrentRecurse == 0) {
 
  135      if (fWriteCurrent.compare_exchange_strong(local, none)) {
 
  155void TCollection::TErrorLock::ReadLock(
const TCollection *collection, 
const char *function)
 
  157   auto local = std::this_thread::get_id();
 
  161      fReadSet.insert(local); 
 
  163   ++fReadCurrentRecurse;
 
  165   if (fWriteCurrentRecurse) {
 
  166      auto holder = fWriteCurrent.load();
 
  167      if (holder != local) ConflictReport(holder, 
"ReadLock with WriteLock taken", collection, function);
 
  171void TCollection::TErrorLock::ReadUnlock()
 
  173   auto local = std::this_thread::get_id();
 
  176      fReadSet.erase(local); 
 
  178   --fReadCurrentRecurse;
 
  200   while ((obj = next()))
 
  211   va_start(ap, 
va_(obj1));
 
  215   while ((obj = va_arg(ap, 
TObject *)))
 
  230      Error(
"AssertClass", 
"class == 0");
 
  234   for (
int i = 0; (obj = next()); i++)
 
  236         Error(
"AssertClass", 
"element %d is not an instance of class %s (%s)",
 
  254      while ((obj = next())) 
b->Add(obj);
 
  266   if (newname && strlen(newname)) new_collection->
SetName(newname);
 
  267   return new_collection;
 
  277   if (
this == obj) 
return 0;
 
  289   while ((
object = next())) {
 
  290      object->Draw(option);
 
  302   while ((
object = next())) {
 
  317   while ((obj = next()))
 
  342   while ((ob = next()))
 
  343      if (ob->
IsEqual(obj)) 
return ob;
 
  363      Error(
"GrowBy", 
"delta < 0");
 
  385   std::cout <<
"OBJ: " << IsA()->GetName() << 
"\t" << 
GetName() << 
"\t" << 
GetTitle() << 
" : " 
  392   if (option) star = (
char*)strchr(option,
'*');
 
  395   while ((
object = next())) {
 
  398         if (s != option && s.
Index(re) == 
kNPOS) 
continue;
 
  410   for (
auto obj : *
this) success &= obj->
Notify();
 
  428   printf(
"Collection name='%s', class='%s', size=%d\n",
 
  449      coll->
Print(option, recurse);
 
  452      entry->
Print(option);
 
  500      while ((
object = next())) {
 
  523      if (!wildcard) wildcard = 
"";
 
  525      Int_t nch = strlen(wildcard);
 
  530      while ((
object = next())) {
 
  532         if (nch == 0 || s == wildcard || s.
Index(re) != 
kNPOS) {
 
  560      while ((
object = next())) {
 
  586   while ((
object = next())) {
 
  599   while ((obj = next()))
 
  606void TCollection::Streamer(
TBuffer &
b)
 
  615         TObject::Streamer(
b);
 
  619      for (
Int_t i = 0; i < nobjects; i++) {
 
  623      b.CheckByteCount(R__s, R__c,TCollection::IsA());
 
  625      R__c = 
b.WriteVersion(TCollection::IsA(), 
kTRUE);
 
  626      TObject::Streamer(
b);
 
  633      while ((obj = next())) {
 
  636      b.SetByteCount(R__c, 
kTRUE);
 
  653      option &= ~kSingleKey;
 
  657      while ((obj = next())) {
 
  658         nbytes += obj->
Write(
name, option, bsize);
 
TVirtualMutex * gCollectionMutex
 
R__EXTERN TVirtualMutex * gCollectionMutex
 
#define R__FOR_EACH(type, proc)
 
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
 
R__EXTERN TSystem * gSystem
 
#define R__LOCKGUARD2(mutex)
 
A spin mutex-as-code-guard class.
 
Using a TBrowser one can browse all ROOT objects.
 
Buffer base class used for serializing objects.
 
TClass instances represent classes, structs and namespaces in the ROOT type system.
 
Bool_t InheritsFrom(const char *cl) const
Return kTRUE if this class inherits from a class with name "classname".
 
Collection abstract base class.
 
virtual void Dump() const
Dump all objects in this collection.
 
virtual TObject * Remove(TObject *obj)=0
 
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const =0
 
virtual void ls(Option_t *option="") const
List (ls) all objects in this collection.
 
virtual Bool_t Notify()
'Notify' all objects in this collection.
 
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
 
virtual void PrintCollectionEntry(TObject *entry, Option_t *option, Int_t recurse) const
Print the collection entry.
 
Bool_t IsArgNull(const char *where, const TObject *obj) const
Returns true if object is a null pointer.
 
virtual const char * GetName() const
Return name of this collection.
 
void SetCurrentCollection()
Set this collection to be the globally accessible collection.
 
static TCollection * GetCurrentCollection()
Return the globally accessible collection.
 
virtual bool UseRWLock(Bool_t enable=true)
Set this collection to use a RW lock upon access, making it thread safe.
 
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
 
static Bool_t fgEmptyingGarbage
 
Bool_t AssertClass(TClass *cl) const
Make sure all objects in this collection inherit from class cl.
 
static Int_t fgGarbageStack
 
virtual Int_t GrowBy(Int_t delta) const
Increase the collection's capacity by delta slots.
 
void SetName(const char *name)
 
virtual void AddAll(const TCollection *col)
Add all objects from collection col to this collection.
 
virtual void Draw(Option_t *option="")
Draw all objects in this collection.
 
virtual void RecursiveRemove(TObject *obj)
Remove object from this collection and recursively remove the object from all other objects (and coll...
 
void Browse(TBrowser *b)
Browse this collection (called by TBrowser).
 
virtual const char * GetCollectionEntryName(TObject *entry) const
For given collection entry return the string that is used to identify the object and,...
 
static void EmptyGarbageCollection()
Do the garbage collection.
 
virtual void PrintCollectionHeader(Option_t *option) const
Print the collection header.
 
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
 
static TCollection * fgCurrentCollection
 
virtual void Add(TObject *obj)=0
 
virtual TObject * Clone(const char *newname="") const
Make a clone of an collection using the Streamer facility.
 
Int_t Compare(const TObject *obj) const
Compare two TCollection objects.
 
static TObjectTable * fgGarbageCollection
 
void AddVector(TObject *obj1,...)
Add all arguments to the collection.
 
virtual ~TCollection()
TNamed destructor.
 
static void StartGarbageCollection()
Set up for garbage collection.
 
static void GarbageCollect(TObject *obj)
Add to the list of things to be cleaned up.
 
virtual void Paint(Option_t *option="")
Paint all objects in this collection.
 
TObject * operator()(const char *name) const
Find an object in this collection by name.
 
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
 
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write all objects in this collection.
 
TIter & Begin()
Pointing to the first element of the container.
 
const TCollection * GetCollection() const
 
static TIter End()
Pointing to the element after the last - to a nullptr value in our case.
 
TIter & operator=(const TIter &rhs)
Assigning an TIter to another.
 
Iterator abstract base class.
 
virtual TObject * Next()=0
 
virtual const char * GetName() const
Returns name of object.
 
This class registers all instances of TObject and its derived classes in a hash table.
 
void Delete(Option_t *opt="")
Delete all objects stored in the TObjectTable.
 
void Add(TObject *obj)
Add an object to the object table.
 
Mother of all ROOT objects.
 
virtual Bool_t Notify()
This method must be overridden to handle object notification.
 
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
 
virtual Bool_t IsEqual(const TObject *obj) const
Default equal comparison (objects are equal if they have the same address in memory).
 
@ kSingleKey
write collection with single key
 
virtual const char * GetName() const
Returns name of object.
 
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
 
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
 
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
 
virtual const char * ClassName() const
Returns name of class to which the object belongs.
 
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
 
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
 
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
 
virtual const char * GetTitle() const
Returns title of object.
 
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
 
@ kCanDelete
if object in a list can be deleted
 
Bool_t MatchB(const TString &s, const TString &mods="", Int_t start=0, Int_t nMaxMatch=10)
 
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
 
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
 
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
 
Regular expression class.
 
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
 
const char * Data() const
 
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
 
virtual void StackTrace()
Print a stack trace.
 
This class implements a mutex interface.
 
R__ALWAYS_INLINE bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
 
bool ContaineeInheritsFrom(TClass *cl, TClass *base)
Return true if 'cl' inherits from 'base'.
 
const TCollection & EmptyCollection()
Return an empty collection for use with nullptr TRangeCast.
 
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.
 
Short_t Range(Short_t lb, Short_t ub, Short_t x)