Loading...
Searching...
No Matches
XrdSysCondVar Class Reference

`#include <XrdSysPthread.hh>`

Collaboration diagram for XrdSysCondVar:

## Public Member Functions

| XrdSysCondVar (int relm=1, const char *cid=0)
| ~XrdSysCondVar ()
void | Broadcast ()
void | Lock ()
void | Signal ()
void | UnLock ()
int | Wait ()
int | Wait (int sec)
int | WaitMS (int msec)

## Detailed Description

Definition at line 78 of file XrdSysPthread.hh.

## Constructor & Destructor Documentation

## XrdSysCondVar()

XrdSysCondVar::XrdSysCondVar | ( | int | relm = 1,
|  | const char * | cid = 0 )

inline

Definition at line 100 of file XrdSysPthread.hh.

{pthread_cond_init(&cvar, NULL);
pthread_mutex_init(&cmut, NULL);
relMutex = relm; condID = (cid ? cid : "unk");
}

## ~XrdSysCondVar()

XrdSysCondVar::~XrdSysCondVar | ( |  | ) |

inline

Definition at line 106 of file XrdSysPthread.hh.

{pthread_cond_destroy(&cvar);
pthread_mutex_destroy(&cmut);
}

## Member Function Documentation

## Broadcast()

void XrdSysCondVar::Broadcast | ( |  | ) |

inline

Definition at line 89 of file XrdSysPthread.hh.

{if (relMutex) pthread_mutex_lock(&cmut);
pthread_cond_broadcast(&cvar);
if (relMutex) pthread_mutex_unlock(&cmut);
}

## Lock()

void XrdSysCondVar::Lock | ( |  | ) |

inline

Definition at line 82 of file XrdSysPthread.hh.

{pthread_mutex_lock(&cmut);}

Referenced by XrdSysCondVarHelper::XrdSysCondVarHelper(), XrdCmsClientMsg::Alloc(), XrdPfc::ResourceMonitor::CrossCheckIfScanIsInProgress(), XrdSysCondVarHelper::Lock(), XrdPfc::ResourceMonitor::perform_initial_scan(), XrdPfc::IOFileBlock::Read(), XrdLink::Terminate(), Wait(), and WaitMS().

Here is the caller graph for this function:

## Signal()

void XrdSysCondVar::Signal | ( |  | ) |

inline

Definition at line 84 of file XrdSysPthread.hh.

{if (relMutex) pthread_mutex_lock(&cmut);
pthread_cond_signal(&cvar);
if (relMutex) pthread_mutex_unlock(&cmut);
}

Referenced by XrdPfc::ResourceMonitor::perform_initial_scan(), XrdPfc::IOFileBlock::Read(), XrdCmsClientMsg::Reply(), and XrdTlsFlush::Setup_Flusher().

Here is the caller graph for this function:

## UnLock()

void XrdSysCondVar::UnLock | ( |  | ) |

inline

Definition at line 94 of file XrdSysPthread.hh.

{pthread_mutex_unlock(&cmut);}

Referenced by XrdPfc::ResourceMonitor::CrossCheckIfScanIsInProgress(), XrdPfc::ResourceMonitor::perform_initial_scan(), XrdPfc::IOFileBlock::Read(), XrdCmsClientMsg::Reply(), XrdLink::Terminate(), Wait(), and WaitMS().

Here is the caller graph for this function:

## Wait() [1/2]

int XrdSysCondVar::Wait | ( |  | ) |

Definition at line 99 of file XrdSysPthread.cc.

{
int retc;
// Wait for the condition
//
if (relMutex) Lock();
retc = pthread_cond_wait(&cvar, &cmut);
if (relMutex) UnLock();
return retc;
}
XrdSysCondVar::UnLock
void UnLock()
Definition XrdSysPthread.hh:94
XrdSysCondVar::Lock
void Lock()
Definition XrdSysPthread.hh:82

References Lock(), and UnLock().

Referenced by XrdPfc::ResourceMonitor::CrossCheckIfScanIsInProgress(), XrdTlsFlush::Flusher(), XrdPfc::IOFileBlock::Read(), and XrdLink::Terminate().

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

## Wait() [2/2]

int XrdSysCondVar::Wait | ( | int | sec | ) |

Definition at line 113 of file XrdSysPthread.cc.

{return WaitMS(sec*1000);}
XrdSysCondVar::WaitMS
int WaitMS(int msec)
Definition XrdSysPthread.cc:119

References WaitMS().

Here is the call graph for this function:

## WaitMS()

int XrdSysCondVar::WaitMS | ( | int | msec | ) |

Definition at line 119 of file XrdSysPthread.cc.

{
int sec, retc, usec;
struct timeval tnow;
struct timespec tval;
// Adjust millseconds
//
if (msec < 1000) sec = 0;
else {sec = msec / 1000; msec = msec % 1000;}
usec = msec * 1000;
// Get the mutex before getting the time
//
if (relMutex) Lock();
// Get current time of day
//
gettimeofday(&tnow, 0);
// Add the second and microseconds
//
tval.tv_sec = tnow.tv_sec + sec;
tval.tv_nsec = tnow.tv_usec + usec;
if (tval.tv_nsec >= 1000000)
{tval.tv_sec += tval.tv_nsec / 1000000;
tval.tv_nsec = tval.tv_nsec % 1000000;
}
tval.tv_nsec *= 1000;
// Now wait for the condition or timeout
//
do {retc = pthread_cond_timedwait(&cvar, &cmut, &tval);}
while (retc && (retc == EINTR));
if (relMutex) UnLock();
// Determine how to return
//
if (retc && retc != ETIMEDOUT) {throw "cond_timedwait() failed";}
return retc == ETIMEDOUT;
}

References Lock(), and UnLock().

Referenced by Wait().

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

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

- XrdSysPthread.hh
- XrdSysPthread.cc