Loading...
Searching...
No Matches
mutex.hpp
Go to the documentation of this file.
/*********************************************************************/
// libthreadar - is a library providing several C++ classes to work with threads
// Copyright (C) 2014-2025 Denis Corbin
//
// This file is part of libthreadar
//
// libthreadar is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libhtreadar 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with libthreadar. If not, see <http://www.gnu.org/licenses/>
//
//----
// to contact the author: dar.linux@free.fr
/*********************************************************************/
#ifndef LIBTHREADAR_MUTEX_HPP
#define LIBTHREADAR_MUTEX_HPP
#include "config.h"
#include "exceptions.hpp"
// C system headers
extern "C"
{
#if HAVE_PTHREAD_H
#include <pthread.h>
#endif
}
// C++ standard headers
#include <string>
// libthreadar headers
namespace libthreadar
{
class mutex
{
public:
mutex();
mutex(const mutex & ref) = delete;
mutex(mutex && ref) = default;
mutex & operator = (const mutex & ref) = delete;
mutex & operator = (mutex && ref) noexcept = default;
virtual ~mutex();
void lock();
void unlock();
bool try_lock();
protected:
pthread_mutex_t mut; //< the mutex
};
} // end of namespace
#endif
libthreadar::mutex
Wrapper around the Posix pthread_mutex_t C objects.
Definition mutex.hpp:57
libthreadar::mutex::unlock
void unlock()
unlock the mutex
libthreadar::mutex::mutex
mutex(const mutex &ref)=delete
no copy constructor
libthreadar::mutex::lock
void lock()
lock the mutex
libthreadar::mutex::mutex
mutex(mutex &&ref)=default
no move constructor
libthreadar::mutex::operator=
mutex & operator=(const mutex &ref)=delete
no assignment operator
libthreadar::mutex::~mutex
virtual ~mutex()
destructor
libthreadar::mutex::mutex
mutex()
constructor
libthreadar::mutex::try_lock
bool try_lock()
Tells whether calling lock() would currently suspend the caller or not.
exceptions.hpp
defines a set of exceptions that are used by libthreadar to report error situations
libthreadar
This is the only namespace used in libthreadar and all symbols provided by libthreadar are member of ...
Definition barrier.hpp:46