XRootD
XrdSysCondVar2 Class Reference

#include <XrdSysPthread.hh>

+ Collaboration diagram for XrdSysCondVar2:

Public Member Functions

 XrdSysCondVar2 (XrdSysMutex &mtx)
 
 ~XrdSysCondVar2 ()
 
void Broadcast ()
 
void Signal ()
 
int Wait ()
 
bool Wait (int sec)
 
bool WaitMS (int msec)
 

Protected Attributes

pthread_cond_t cvar
 
pthread_mutex_t * mtxP
 

Detailed Description

Definition at line 299 of file XrdSysPthread.hh.

Constructor & Destructor Documentation

◆ XrdSysCondVar2()

XrdSysCondVar2::XrdSysCondVar2 ( XrdSysMutex mtx)
inline

Definition at line 311 of file XrdSysPthread.hh.

311  : mtxP(&mtx.cs)
312  {pthread_cond_init(&cvar, NULL);}
pthread_mutex_t * mtxP
pthread_cond_t cvar
pthread_mutex_t cs

References cvar.

◆ ~XrdSysCondVar2()

XrdSysCondVar2::~XrdSysCondVar2 ( )
inline

Definition at line 314 of file XrdSysPthread.hh.

314 {pthread_cond_destroy(&cvar);}

References cvar.

Member Function Documentation

◆ Broadcast()

void XrdSysCondVar2::Broadcast ( )
inline

Definition at line 305 of file XrdSysPthread.hh.

305 {pthread_cond_broadcast(&cvar);}

References cvar.

◆ Signal()

void XrdSysCondVar2::Signal ( )
inline

Definition at line 303 of file XrdSysPthread.hh.

303 {pthread_cond_signal(&cvar);}

References cvar.

◆ Wait() [1/2]

int XrdSysCondVar2::Wait ( )
inline

Definition at line 307 of file XrdSysPthread.hh.

307 {return pthread_cond_wait(&cvar, mtxP);}

References cvar, and mtxP.

Referenced by XrdXrootdProtocol::Recycle().

+ Here is the caller graph for this function:

◆ Wait() [2/2]

bool XrdSysCondVar2::Wait ( int  sec)
inline

Definition at line 308 of file XrdSysPthread.hh.

308 {return WaitMS(sec*1000);}
bool WaitMS(int msec)

References WaitMS().

+ Here is the call graph for this function:

◆ WaitMS()

bool XrdSysCondVar2::WaitMS ( int  msec)

Definition at line 170 of file XrdSysPthread.cc.

171 {
172  int sec, retc, usec;
173  struct timeval tnow;
174  struct timespec tval;
175 
176 // Adjust millseconds
177 //
178  if (msec < 1000) sec = 0;
179  else {sec = msec / 1000; msec = msec % 1000;}
180  usec = msec * 1000;
181 
182 // Get current time of day
183 //
184  gettimeofday(&tnow, 0);
185 
186 // Add the second and microseconds
187 //
188  tval.tv_sec = tnow.tv_sec + sec;
189  tval.tv_nsec = tnow.tv_usec + usec;
190  if (tval.tv_nsec >= 1000000)
191  {tval.tv_sec += tval.tv_nsec / 1000000;
192  tval.tv_nsec = tval.tv_nsec % 1000000;
193  }
194  tval.tv_nsec *= 1000;
195 
196 
197 // Now wait for the condition or timeout
198 //
199  do {retc = pthread_cond_timedwait(&cvar, mtxP, &tval);}
200  while (retc && (retc == EINTR));
201 
202 // Determine how to return
203 //
204  if (retc && retc != ETIMEDOUT) {throw "cond_timedwait() failed";}
205  return retc == ETIMEDOUT;
206 }

References cvar, and mtxP.

Referenced by Wait().

+ Here is the caller graph for this function:

Member Data Documentation

◆ cvar

pthread_cond_t XrdSysCondVar2::cvar
protected

Definition at line 318 of file XrdSysPthread.hh.

Referenced by XrdSysCondVar2(), ~XrdSysCondVar2(), Broadcast(), Signal(), Wait(), and WaitMS().

◆ mtxP

pthread_mutex_t* XrdSysCondVar2::mtxP
protected

Definition at line 319 of file XrdSysPthread.hh.

Referenced by Wait(), and WaitMS().


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