2015-08-19 18:27:29 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Colobot: Gold Edition source code
|
2016-02-13 13:11:30 +00:00
|
|
|
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
|
2015-08-22 14:40:02 +00:00
|
|
|
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
2015-08-19 18:27:29 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see http://gnu.org/licenses
|
|
|
|
*/
|
|
|
|
|
2015-08-04 18:30:31 +00:00
|
|
|
#pragma once
|
|
|
|
|
2016-07-10 12:56:34 +00:00
|
|
|
#include "common/thread/sdl_mutex_wrapper.h"
|
|
|
|
|
2015-08-04 18:30:31 +00:00
|
|
|
#include <SDL_thread.h>
|
|
|
|
|
2015-08-04 18:57:53 +00:00
|
|
|
/**
|
|
|
|
* \class CSDLCondWrapper
|
|
|
|
* \brief Wrapper for safe creation/deletion of SDL_cond
|
|
|
|
*/
|
|
|
|
class CSDLCondWrapper
|
2015-08-04 18:30:31 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-08-04 18:57:53 +00:00
|
|
|
CSDLCondWrapper()
|
2015-08-04 18:30:31 +00:00
|
|
|
: m_cond(SDL_CreateCond())
|
|
|
|
{}
|
|
|
|
|
2015-08-04 18:57:53 +00:00
|
|
|
~CSDLCondWrapper()
|
2015-08-04 18:30:31 +00:00
|
|
|
{
|
|
|
|
SDL_DestroyCond(m_cond);
|
|
|
|
}
|
|
|
|
|
2015-08-04 18:57:53 +00:00
|
|
|
CSDLCondWrapper(const CSDLCondWrapper&) = delete;
|
|
|
|
CSDLCondWrapper& operator=(const CSDLCondWrapper&) = delete;
|
2015-08-04 18:30:31 +00:00
|
|
|
|
|
|
|
SDL_cond* operator*()
|
|
|
|
{
|
|
|
|
return m_cond;
|
|
|
|
}
|
|
|
|
|
2016-07-10 12:56:34 +00:00
|
|
|
void Signal()
|
|
|
|
{
|
|
|
|
SDL_CondSignal(m_cond);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Wait(SDL_mutex* mutex)
|
|
|
|
{
|
|
|
|
SDL_CondWait(m_cond, mutex);
|
|
|
|
}
|
|
|
|
|
2015-08-04 18:30:31 +00:00
|
|
|
private:
|
|
|
|
SDL_cond* m_cond;
|
|
|
|
};
|