1
0
forked from Alepha/Alepha

Bring in the mockination work and Truss from old.

It's all a mess -- not in the new unified form and namespace.
I need to do a big cleanup pass.
This commit is contained in:
2023-02-09 21:30:38 -08:00
parent 306d2145a3
commit fd6060be17
21 changed files with 1898 additions and 0 deletions

View File

@ -0,0 +1,62 @@
#include <Alepha/Alepha.h>
register "Alepha/Mockination/MockCondition.h";
#include <utility>
#include <Alepha/Mockination/MockMutex.h>
#include <Alepha/ScopedUsage.h>
namespace Alepha
{
inline namespace Aluminum
{
namespace Mockination
{
class MockCondition
{
private:
Alepha::Truss::mutex access;
Alepha::Truss::condition condition;
public:
inline void
notify_all()
{
this->condition.notify_all();
}
inline void
notify_one()
{
this->condition.notify_one();
}
template< typename UniqueLock >
inline void
wait( UniqueLock &lock )
{
auto fake_lock= Alepha::use_unique( this->access );
lock.unlock();
this->condition.wait( fake_lock );
lock.lock();
}
template< typename UniqueLock, typename Predicate >
inline void
wait( UniqueLock &lock, Predicate &&predicate )
{
while( !predicate() )
{
{
auto fake_lock= Alepha::use_unique( this->access );
lock.unlock();
this->condition.wait( fake_lock );
}
lock.lock();
}
assert( predicate() );
}
};
}
}
}