Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/Lazy.cs')
-rw-r--r--mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/Lazy.cs80
1 files changed, 0 insertions, 80 deletions
diff --git a/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/Lazy.cs b/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/Lazy.cs
deleted file mode 100644
index 6d3b11acfb3..00000000000
--- a/mcs/class/System.ComponentModel.Composition/src/ComponentModel/System/Lazy.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-// -----------------------------------------------------------------------
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// -----------------------------------------------------------------------
-#if !CLR40
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using Microsoft.Internal;
-
-namespace System
-{
- public class Lazy<T>
- {
- private T _value = default(T);
- private volatile bool _isValueCreated = false;
- private Func<T> _valueFactory = null;
- private object _lock;
-
- public Lazy()
- : this(() => Activator.CreateInstance<T>())
- {
- }
-
- public Lazy(bool isThreadSafe)
- : this(() => Activator.CreateInstance<T>(), isThreadSafe)
- {
- }
-
- public Lazy(Func<T> valueFactory):
- this(valueFactory, true)
- {
- }
-
- public Lazy(Func<T> valueFactory, bool isThreadSafe)
- {
- Requires.NotNull(valueFactory, "valueFactory");
- if(isThreadSafe)
- {
- this._lock = new object();
- }
-
- this._valueFactory = valueFactory;
- }
-
-
- public T Value
- {
- get
- {
- if (!this._isValueCreated)
- {
- if(this._lock != null)
- {
- Monitor.Enter(this._lock);
- }
-
- try
- {
- T value = this._valueFactory.Invoke();
- this._valueFactory = null;
- Thread.MemoryBarrier();
- this._value = value;
- this._isValueCreated = true;
- }
- finally
- {
- if(this._lock != null)
- {
- Monitor.Exit(this._lock);
- }
- }
- }
- return this._value;
- }
- }
- }
-}
-#endif