XRootD
XrdOssCsiRanges Class Reference

#include <XrdOssCsiRanges.hh>

+ Collaboration diagram for XrdOssCsiRanges:

Public Member Functions

 XrdOssCsiRanges ()
 
 ~XrdOssCsiRanges ()
 
void AddRange (const off_t start, const off_t end, XrdOssCsiRangeGuard &rg, bool rdonly)
 
void RemoveRange (XrdOssCsiRange_s *rp)
 
void Wait (XrdOssCsiRange_s *rp)
 

Detailed Description

Definition at line 100 of file XrdOssCsiRanges.hh.

Constructor & Destructor Documentation

◆ XrdOssCsiRanges()

XrdOssCsiRanges::XrdOssCsiRanges ( )
inline

Definition at line 103 of file XrdOssCsiRanges.hh.

103 : allocList_(NULL) { }

◆ ~XrdOssCsiRanges()

XrdOssCsiRanges::~XrdOssCsiRanges ( )
inline

Definition at line 105 of file XrdOssCsiRanges.hh.

106  {
107  XrdOssCsiRange_s *p;
108  while((p = allocList_))
109  {
110  allocList_ = allocList_->next;
111  delete p;
112  }
113  }
XrdOssCsiRange_s * next

References XrdOssCsiRange_s::next.

Member Function Documentation

◆ AddRange()

void XrdOssCsiRanges::AddRange ( const off_t  start,
const off_t  end,
XrdOssCsiRangeGuard rg,
bool  rdonly 
)
inline

Definition at line 118 of file XrdOssCsiRanges.hh.

119  {
120  std::unique_lock<std::mutex> lck(rmtx_);
121 
122  int nblocking = 0;
123  for(auto itr = ranges_.begin(); itr != ranges_.end(); ++itr)
124  {
125  if ((*itr)->start <= end && start <= (*itr)->end)
126  {
127  if (!(rdonly && (*itr)->rdonly))
128  {
129  nblocking++;
130  }
131  }
132  }
133 
134  XrdOssCsiRange_s *nr = AllocRange();
135  nr->start = start;
136  nr->end = end;
137  nr->rdonly = rdonly;
138  nr->nBlockedBy = nblocking;
139  ranges_.push_back(nr);
140  lck.unlock();
141 
142  rg.SetRange(this, nr);
143  }
void SetRange(XrdOssCsiRanges *r, XrdOssCsiRange_s *rp)

References XrdOssCsiRange_s::end, XrdOssCsiRange_s::nBlockedBy, XrdOssCsiRange_s::rdonly, XrdOssCsiRangeGuard::SetRange(), and XrdOssCsiRange_s::start.

Referenced by XrdOssCsiPages::LockTrackinglen().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveRange()

void XrdOssCsiRanges::RemoveRange ( XrdOssCsiRange_s rp)
inline

Definition at line 154 of file XrdOssCsiRanges.hh.

155  {
156  std::lock_guard<std::mutex> guard(rmtx_);
157  for(auto itr=ranges_.begin();itr!=ranges_.end();++itr)
158  {
159  if (*itr == rp)
160  {
161  ranges_.erase(itr);
162  break;
163  }
164  }
165 
166  for(auto itr=ranges_.begin(); itr != ranges_.end(); ++itr)
167  {
168  if ((*itr)->start <= rp->end && rp->start <= (*itr)->end)
169  {
170  if (!(rp->rdonly && (*itr)->rdonly))
171  {
172  std::unique_lock<std::mutex> l((*itr)->mtx);
173  (*itr)->nBlockedBy--;
174  if ((*itr)->nBlockedBy == 0)
175  {
176  (*itr)->cv.notify_one();
177  }
178  }
179  }
180  }
181 
182  RecycleRange(rp);
183  rp = NULL;
184  }

References XrdOssCsiRange_s::end, XrdOssCsiRange_s::rdonly, and XrdOssCsiRange_s::start.

Referenced by XrdOssCsiRangeGuard::ReleaseAll().

+ Here is the caller graph for this function:

◆ Wait()

void XrdOssCsiRanges::Wait ( XrdOssCsiRange_s rp)
inline

Definition at line 145 of file XrdOssCsiRanges.hh.

146  {
147  std::unique_lock<std::mutex> l(rp->mtx);
148  while (rp->nBlockedBy>0)
149  {
150  rp->cv.wait(l);
151  }
152  }
std::condition_variable cv

References XrdOssCsiRange_s::cv, XrdOssCsiRange_s::mtx, and XrdOssCsiRange_s::nBlockedBy.

Referenced by XrdOssCsiRangeGuard::Wait().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: