semaphore.cpp

来自「一个语言识别引擎」· C++ 代码 · 共 41 行

CPP
41
字号
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

/*
 * Copyright (C) 2006 Paul Fitzpatrick
 * CopyPolicy: Released under the terms of the GNU GPL v2.0.
 *
 */


#include <yarp/os/Semaphore.h>
#include <yarp/Logger.h>
#include <yarp/SemaphoreImpl.h>

using namespace yarp;
using namespace yarp::os;

Semaphore::Semaphore(int initialCount) {
    implementation = new SemaphoreImpl(initialCount);
    YARP_ASSERT(implementation!=NULL);
}

Semaphore::~Semaphore() {
    if (implementation!=NULL) {
        delete ((SemaphoreImpl*)implementation);
        implementation = NULL;
    }
}

void Semaphore::wait() {
    ((SemaphoreImpl*)implementation)->wait();
}

bool Semaphore::check() {
    return ((SemaphoreImpl*)implementation)->check();
}

void Semaphore::post() {
    ((SemaphoreImpl*)implementation)->post();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?