nsprpub/pr/src/cplus/rccv.cpp

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /*
michael@0 7 ** RCCondition - C++ wrapper around NSPR's PRCondVar
michael@0 8 */
michael@0 9
michael@0 10 #include "rccv.h"
michael@0 11
michael@0 12 #include <prlog.h>
michael@0 13 #include <prerror.h>
michael@0 14 #include <prcvar.h>
michael@0 15
michael@0 16 RCCondition::RCCondition(class RCLock *lock): RCBase()
michael@0 17 {
michael@0 18 cv = PR_NewCondVar(lock->lock);
michael@0 19 PR_ASSERT(NULL != cv);
michael@0 20 timeout = PR_INTERVAL_NO_TIMEOUT;
michael@0 21 } /* RCCondition::RCCondition */
michael@0 22
michael@0 23 RCCondition::~RCCondition()
michael@0 24 {
michael@0 25 if (NULL != cv) PR_DestroyCondVar(cv);
michael@0 26 } /* RCCondition::~RCCondition */
michael@0 27
michael@0 28 PRStatus RCCondition::Wait()
michael@0 29 {
michael@0 30 PRStatus rv;
michael@0 31 PR_ASSERT(NULL != cv);
michael@0 32 if (NULL == cv)
michael@0 33 {
michael@0 34 SetError(PR_INVALID_ARGUMENT_ERROR, 0);
michael@0 35 rv = PR_FAILURE;
michael@0 36 }
michael@0 37 else
michael@0 38 rv = PR_WaitCondVar(cv, timeout.interval);
michael@0 39 return rv;
michael@0 40 } /* RCCondition::Wait */
michael@0 41
michael@0 42 PRStatus RCCondition::Notify()
michael@0 43 {
michael@0 44 return PR_NotifyCondVar(cv);
michael@0 45 } /* RCCondition::Notify */
michael@0 46
michael@0 47 PRStatus RCCondition::Broadcast()
michael@0 48 {
michael@0 49 return PR_NotifyAllCondVar(cv);
michael@0 50 } /* RCCondition::Broadcast */
michael@0 51
michael@0 52 PRStatus RCCondition::SetTimeout(const RCInterval& tmo)
michael@0 53 {
michael@0 54 if (NULL == cv)
michael@0 55 {
michael@0 56 SetError(PR_INVALID_ARGUMENT_ERROR, 0);
michael@0 57 return PR_FAILURE;
michael@0 58 }
michael@0 59 timeout = tmo;
michael@0 60 return PR_SUCCESS;
michael@0 61 } /* RCCondition::SetTimeout */
michael@0 62
michael@0 63 RCInterval RCCondition::GetTimeout() const { return timeout; }
michael@0 64
michael@0 65 /* rccv.cpp */

mercurial