1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
** RCCondition - C++ wrapper around NSPR's PRCondVar
16
RCCondition::RCCondition(class RCLock *lock): RCBase()
18
cv = PR_NewCondVar(lock->lock);
19
PR_ASSERT(NULL != cv);
20
timeout = PR_INTERVAL_NO_TIMEOUT;
21
} /* RCCondition::RCCondition */
23
RCCondition::~RCCondition()
25
if (NULL != cv) PR_DestroyCondVar(cv);
26
} /* RCCondition::~RCCondition */
28
PRStatus RCCondition::Wait()
31
PR_ASSERT(NULL != cv);
34
SetError(PR_INVALID_ARGUMENT_ERROR, 0);
38
rv = PR_WaitCondVar(cv, timeout.interval);
40
} /* RCCondition::Wait */
42
PRStatus RCCondition::Notify()
44
return PR_NotifyCondVar(cv);
45
} /* RCCondition::Notify */
47
PRStatus RCCondition::Broadcast()
49
return PR_NotifyAllCondVar(cv);
50
} /* RCCondition::Broadcast */
52
PRStatus RCCondition::SetTimeout(const RCInterval& tmo)
56
SetError(PR_INVALID_ARGUMENT_ERROR, 0);
61
} /* RCCondition::SetTimeout */
63
RCInterval RCCondition::GetTimeout() const { return timeout; }