Some improvements to Lazy<T> class.
This commit is contained in:
parent
562911dbff
commit
5673c6f14a
@ -52,20 +52,26 @@ namespace MUtils
|
||||
|
||||
T& operator*(void)
|
||||
{
|
||||
while (!m_value)
|
||||
T *value;
|
||||
do
|
||||
{
|
||||
if (T *const value = m_initializer())
|
||||
if (!(value = m_value.fetchAndAddOrdered(0)))
|
||||
{
|
||||
if (value = m_initializer())
|
||||
{
|
||||
if (!m_value.testAndSetOrdered(NULL, value))
|
||||
{
|
||||
delete value; /*too late*/
|
||||
delete value;
|
||||
value = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MUTILS_THROW("Initializer returned NULL!");
|
||||
MUTILS_THROW("Initializer returned NULL pointer!");
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!value);
|
||||
return *m_value;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user