ROOT
master
Reference Guide
Loading...
Searching...
No Matches
RSlotStack.cxx
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
#include <
ROOT/RSlotStack.hxx
>
12
13
#include <stdexcept>
14
#include <string>
15
16
ROOT::Internal::RSlotStack::RSlotStack
(
unsigned
int
size
) : fSlots(
size
) {}
17
18
void
ROOT::Internal::RSlotStack::ReturnSlot
(
unsigned
int
slot
)
19
{
20
if
(
slot
>= fSlots.size())
21
throw
std::invalid_argument(
"RSlotStack: A slot that is larger than the number of slots was returned :"
+
22
std::to_string(
slot
));
23
bool
expected
=
true
;
24
if
(!fSlots[
slot
].fAtomic.compare_exchange_strong(
expected
,
false
))
25
throw
std::logic_error(
"RSlotStack: A slot that is not assigned was returned: "
+ std::to_string(
slot
));
26
}
27
28
unsigned
int
ROOT::Internal::RSlotStack::GetSlot
()
29
{
30
while
(
true
) {
31
for
(
unsigned
int
i = 0; i < fSlots.size(); ++i) {
32
// test if a slot is available (assigned == false)
33
bool
expectedState
=
false
;
34
if
(fSlots[i].fAtomic.compare_exchange_strong(
expectedState
,
true
)) {
35
return
i;
36
}
37
}
38
}
39
}
RSlotStack.hxx
size
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
ROOT::Internal::RSlotStack::GetSlot
unsigned int GetSlot()
Definition
RSlotStack.cxx:28
ROOT::Internal::RSlotStack::RSlotStack
RSlotStack()=delete
ROOT::Internal::RSlotStack::ReturnSlot
void ReturnSlot(unsigned int slotNumber)
Definition
RSlotStack.cxx:18
core
imt
src
RSlotStack.cxx
ROOT master - Reference Guide Generated on Thu Jul 17 2025 15:09:17 (GVA Time) using Doxygen 1.10.0