/* Blinker
Copyright 2011-2019 Stefan Schuermans <stefan@blinkenarea.org>
Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
a blinkenarea.org project */
#ifndef BLINKER_LOCK_H
#define BLINKER_LOCK_H
namespace Blinker {
/// a mutual exclusion lock (easy, because Blinker is single-threaded)
class Lock
{
public:
/// constructor
Lock();
/// destructor
~Lock();
private:
/// copy constructor disabled
Lock(const Lock &that);
/// assignment operator disabled
const Lock & operator=(const Lock &that);
public:
/**
* @brief check if locked
* @return whether lock is taken
*/
bool islocked() const;
/**
* @brief lock if not locked
* @return whether lock could be acquired
*/
bool trylock();
/// unlock (if locked)
void unlock();
private:
bool m_locked; ///< whether lock is locked
}; // class Lock
} // namespace Blinker
#endif // #ifndef BLINKER_LOCK_H