merged concurrent to main library

removed PIConditionLock, use PIMutex instead
This commit is contained in:
2020-07-30 18:50:42 +03:00
parent 4dd59132d5
commit 2ffc457566
31 changed files with 558 additions and 2176 deletions

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
PIMutexLocker
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Stephan Fomenko, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -24,6 +24,45 @@
#define PIMUTEX_H
#include "piinit.h"
#include <mutex>
class PIP_EXPORT PIMutex
{
public:
NO_COPY_CLASS(PIMutex)
//! Constructs unlocked mutex
explicit PIMutex();
//! Destroy mutex
~PIMutex();
//! \brief Lock mutex
//! \details If mutex is unlocked it set to locked state and returns immediate.
//! If mutex is already locked function blocks until mutex will be unlocked
void lock();
//! \brief Unlock mutex
//! \details In any case this function returns immediate
void unlock() ;
//! \brief Try to lock mutex
//! \details If mutex is unlocked it set to locked state and returns "true" immediate.
//! If mutex is already locked function returns immediate an returns "false"
bool tryLock();
void * handle();
private:
void init();
void destroy();
PRIVATE_DECLARATION
};
//! \brief PIMutexLocker
//! \details Same as std::lock_guard<std::mutex>.
@@ -40,7 +79,7 @@ public:
~PIMutexLocker() {if (cond) mutex.unlock();}
private:
PIMutex & mutex;
std::atomic_bool cond;
bool cond;
};
#endif // PIMUTEX_H