Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RSlotStack.hxx
Go to the documentation of this file.
1 // Author: Enrico Guiraud, Danilo Piparo CERN 03/2017
2 
3 /*************************************************************************
4  * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 #ifndef ROOT_RSLOTSTACK
12 #define ROOT_RSLOTSTACK
13 
14 #include <ROOT/TSpinMutex.hxx>
15 
16 #include <stack>
17 
18 namespace ROOT {
19 namespace Internal {
20 namespace RDF {
21 
22 /// This is an helper class to allow to pick a slot resorting to a map
23 /// indexed by thread ids.
24 /// WARNING: this class does not work as a regular stack. The size is
25 /// fixed at construction time and no blocking is foreseen.
26 class RSlotStack {
27 private:
28  const unsigned int fSize;
29  std::stack<unsigned int> fStack;
30  ROOT::TSpinMutex fMutex;
31 
32 public:
33  RSlotStack() = delete;
34  RSlotStack(unsigned int size);
35  void ReturnSlot(unsigned int slotNumber);
36  unsigned int GetSlot();
37 };
38 } // namespace RDF
39 } // namespace Internal
40 } // namespace ROOT
41 
42 #endif