first commit

This commit is contained in:
2026-06-22 11:49:35 +02:00
commit d805f2ba86
619 changed files with 126873 additions and 0 deletions

View File

@ -0,0 +1,67 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NFUTURE__
#define __NFUTURE__
#include "thread/atomic_value.h"
#include "memory/nshared_ptr.h"
namespace GS {
namespace ASync {
/*
@short Future.
@author Emmanuel Julien (ejulien@nworks.fr)
*/
template <class T> class Future
{
T value;
Threading::Atomic32 set;
public:
bool IsSet() const
{ return set.Get() == 1; }
void Set(const T &_value)
{
value = _value;
set.Set(1);
}
void Wait()
{ while (!IsSet()); }
T &Get()
{
Wait();
return value;
}
};
//
template <> class Future <void>
{
Threading::Atomic32 set;
public:
bool IsSet() const
{ return set.Get() == 1; }
void Set()
{ set.Set(1); }
void Wait()
{ while (!IsSet()); }
};
} // ASync
} // GS
#endif // __NFUTURE__