mirror of
https://github.com/digital-jellyfish/Virtu.git
synced 2024-05-31 15:41:33 +00:00
7aacc26962
Added 'default' debug service using Trace output. Added more debug service logging to machine.
36 lines
792 B
C#
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;
|
|
}
|
|
}
|