blob: d4be702d934ad5d0a22396a8a89d54703bb92eff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
using System;
namespace jive.utility
{
static public class FuncExtensions
{
static public readonly object mutex = new object();
static public Func<T> memorize<T>(this Func<T> item) where T : class
{
T the_implementation = null;
return () =>
{
if (null == the_implementation)
{
lock (mutex)
{
if (null == the_implementation)
{
the_implementation = item();
}
}
}
return the_implementation;
};
}
}
}
|