Virtu/Library/Lazy.cs
Sean Fausett 7aacc26962 Added support for 'executable' (.xex) files.
Added 'default' debug service using Trace output.
Added more debug service logging to machine.
2012-07-08 16:18:07 +12:00

36 lines
792 B
C#

using System;
namespace Jellyfish.Library
{
public sealed class Lazy<T> where T : class
{
public Lazy(Func<T> initializer)
{
_initializer = initializer;
}
public T Value
{
get
{
if (_value == null)
{
lock (_lock)
{
if (_value == null)
{
_value = _initializer();
}
}
}
return _value;
}
}
private Func<T> _initializer;
private readonly object _lock = new object();
private volatile T _value;
}
}