Logo ROOT  
Reference Guide
RConcurrentHashColl.cxx
Go to the documentation of this file.
3#include <ROOT/TSeq.hxx>
4#include <ROOT/RSha256.hxx>
5
6#include <memory>
7#include <set>
8
9namespace ROOT {
10namespace Internal {
11
12
13std::ostream &operator<<(std::ostream &os, const RConcurrentHashColl::HashValue &h)
14{
15 auto digest = h.Get();
16 os << digest[0] << "-" << digest[1] << "-" << digest[2] << "-" << digest[3];
17 return os;
18}
19
21{
22 // The cast here is because in the TBuffer ecosystem, the type used is char*
23 Sha256(reinterpret_cast<const unsigned char *>(data), len, fDigest);
24}
25
26struct RHashSet {
27 std::set<ROOT::Internal::RConcurrentHashColl::HashValue> fSet;
28};
29
31 : fHashSet(std::make_unique<RHashSet>()), fRWLock(std::make_unique<ROOT::TRWSpinLock>()){};
32
34
35/// Return true if the hash is already in already there
36bool RConcurrentHashColl::Find(const HashValue &hash) const
37{
39 return (fHashSet->fSet.end() != fHashSet->fSet.find(hash));
40}
41
42/// If the buffer is there, return false. Otherwise, insert the hash and return true
44{
45 return HashValue(buffer, len);
46}
47
48/// If the buffer is there, return false. Otherwise, insert the hash and return true
49bool RConcurrentHashColl::Insert(char *buffer, int len) const
50{
51 HashValue hash(buffer, len);
52
53 {
55 if (fHashSet->fSet.end() != fHashSet->fSet.find(hash))
56 return false;
57 }
58 {
60 fHashSet->fSet.insert(hash);
61 return true;
62 }
63}
64
65/// If the buffer is there, return false. Otherwise, insert the hash and return true
67{
69 auto ret = fHashSet->fSet.insert(hash);
70 return ret.second;
71}
72
73} // End NS Internal
74} // End NS ROOT
#define h(i)
Definition: RSha256.hxx:106
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
bool Insert(char *buf, int len) const
If the hash is there, return false. Otherwise, insert the hash and return true;.
std::unique_ptr< RHashSet > fHashSet
static HashValue Hash(char *buf, int len)
Return the hash object corresponding to the buffer.
std::unique_ptr< ROOT::TRWSpinLock > fRWLock
bool Find(const HashValue &hash) const
Return true if the hash is already in already there.
std::ostream & operator<<(std::ostream &os, const RConcurrentHashColl::HashValue &h)
void Sha256(const unsigned char *data, int len, ULong64_t *fDigest)
Definition: RSha256.hxx:267
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
std::set< ROOT::Internal::RConcurrentHashColl::HashValue > fSet