Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RConcurrentHashColl.hxx
Go to the documentation of this file.
1// Author: Danilo Piparo May 2018
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_RConcurrentHashColl
12#define ROOT_RConcurrentHashColl
13
14#include <memory>
15#include "Rtypes.h"
16
17namespace ROOT {
18
19class TRWSpinLock;
20
21namespace Internal {
22
23struct RHashSet;
24
25/// This class is a TS set of unsigned set
27private:
28 mutable std::unique_ptr<RHashSet> fHashSet;
29 mutable std::unique_ptr<ROOT::TRWSpinLock> fRWLock;
30
31public:
32 class HashValue {
33 friend std::ostream &operator<<(std::ostream &os, const RConcurrentHashColl::HashValue &h);
34 private:
35 ULong64_t fDigest[4] = {0, 0, 0, 0};
36
37 public:
38 HashValue() = default;
39 HashValue(const char *data, int len);
40 ULong64_t const *Get() const { return fDigest; }
41 };
42
45
46 /// Return true if the hash is already in already there
47 bool Find(const HashValue &hash) const;
48
49 /// If the hash is there, return false. Otherwise, insert the hash and return true;
50 bool Insert(const HashValue &hash) const;
51
52 /// Return the hash object corresponding to the buffer.
53 static HashValue Hash(char *buf, int len);
54};
55
57{
58 auto l = lhs.Get();
59 auto r = rhs.Get();
60 return l[0] == r[0] && l[1] == r[1] && l[2] == r[2] && l[3] == r[3];
61}
62
63} // End NS Internal
64} // End NS ROOT
65
66namespace std {
67template <>
68struct less<ROOT::Internal::RConcurrentHashColl::HashValue> {
70 {
71 /// Check piece by piece the 4 64 bits ints which make up the hash.
72 auto l = lhs.Get();
73 auto r = rhs.Get();
74 // clang-format off
75 return l[0] < r[0] ? true :
76 l[0] > r[0] ? false :
77 l[1] < r[1] ? true :
78 l[1] > r[1] ? false :
79 l[2] < r[2] ? true :
80 l[2] > r[2] ? false :
81 l[3] < r[3] ? true : false;
82 // clang-format on
83 }
84};
85} // End NS std
86
87#endif
#define h(i)
Definition RSha256.hxx:106
unsigned long long ULong64_t
Definition RtypesCore.h:81
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 r
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
TRObject operator()(const T1 &t1) const
friend std::ostream & operator<<(std::ostream &os, const RConcurrentHashColl::HashValue &h)
This class is a TS set of unsigned set.
static HashValue Hash(char *buf, int len)
Return the hash object corresponding to the buffer.
std::unique_ptr< ROOT::TRWSpinLock > fRWLock
bool Insert(const HashValue &hash) const
If the hash is there, return false. Otherwise, insert the hash and return true;.
bool Find(const HashValue &hash) const
Return true if the hash is already in already there.
An implementation of a read-write lock with an internal spin lock.
bool operator==(const RConcurrentHashColl::HashValue &lhs, const RConcurrentHashColl::HashValue &rhs)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
TLine l
Definition textangle.C:4