XRootD
Loading...
Searching...
No Matches
XrdSysSemWait Class Reference

#include <XrdSysSemWait.hh>

+ Collaboration diagram for XrdSysSemWait:

Public Member Functions

 XrdSysSemWait (int semval=1, const char *cid=0)
 
 ~XrdSysSemWait ()
 
int CondWait ()
 
void Post ()
 
void Wait ()
 
int Wait (int secs)
 

Detailed Description

Definition at line 34 of file XrdSysSemWait.hh.

Constructor & Destructor Documentation

◆ XrdSysSemWait()

XrdSysSemWait::XrdSysSemWait ( int  semval = 1,
const char *  cid = 0 
)
inline

Definition at line 109 of file XrdSysSemWait.hh.

109 : semVar(0, cid) {
110 semVal = semval; semWait = 0;
111 }

◆ ~XrdSysSemWait()

XrdSysSemWait::~XrdSysSemWait ( )
inline

Definition at line 113 of file XrdSysSemWait.hh.

113{}

Member Function Documentation

◆ CondWait()

int XrdSysSemWait::CondWait ( )
inline

Definition at line 37 of file XrdSysSemWait.hh.

37 {
38
39 int rc = 0;
40 // Wait until the sempahore value is positive. This will not be starvation
41 // free is the OS implements an unfair mutex;
42 // Returns 0 if signalled, non-0 if would block
43 //
44
45 semVar.Lock();
46 if (semVal > 0) semVal--;
47 else {
48 rc = 1;
49 }
50
51 semVar.UnLock();
52
53 return rc;
54
55 };

References XrdSysCondVar::Lock(), and XrdSysCondVar::UnLock().

+ Here is the call graph for this function:

◆ Post()

void XrdSysSemWait::Post ( )
inline

Definition at line 57 of file XrdSysSemWait.hh.

57 {
58 // Add one to the semaphore counter. If we the value is > 0 and there is a
59 // thread waiting for the sempagore, signal it to get the semaphore.
60 //
61 semVar.Lock();
62
63 if (semWait > 0) {
64 semVar.Signal();
65 semWait--;
66 }
67 else
68 semVal++;
69
70 semVar.UnLock();
71 };

References XrdSysCondVar::Lock(), XrdSysCondVar::Signal(), and XrdSysCondVar::UnLock().

+ Here is the call graph for this function:

◆ Wait() [1/2]

void XrdSysSemWait::Wait ( )
inline

Definition at line 73 of file XrdSysSemWait.hh.

73 {
74 // Wait until the sempahore value is positive. This will not be starvation
75 // free is the OS implements an unfair mutex;
76 //
77
78 semVar.Lock();
79 if (semVal > 0) semVal--;
80 else {
81 semWait++;
82 semVar.Wait();
83 }
84
85 semVar.UnLock();
86
87 };

References XrdSysCondVar::Lock(), XrdSysCondVar::UnLock(), and XrdSysCondVar::Wait().

+ Here is the call graph for this function:

◆ Wait() [2/2]

int XrdSysSemWait::Wait ( int  secs)
inline

Definition at line 89 of file XrdSysSemWait.hh.

89 {
90 int rc = 0;
91 // Wait until the sempahore value is positive. This will not be starvation
92 // free is the OS implements an unfair mutex;
93 // Returns 0 if signalled, non-0 if timeout
94 //
95
96 semVar.Lock();
97 if (semVal > 0) semVal--;
98 else {
99 semWait++;
100 rc = semVar.Wait(secs);
101 if (rc) semWait--;
102 }
103
104 semVar.UnLock();
105
106 return rc;
107 };

References XrdSysCondVar::Lock(), XrdSysCondVar::UnLock(), and XrdSysCondVar::Wait().

+ Here is the call graph for this function:

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