forked from KSemenenko/TimePeriodLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClockProxy.cs
More file actions
51 lines (45 loc) · 1.18 KB
/
ClockProxy.cs
File metadata and controls
51 lines (45 loc) · 1.18 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// -- FILE ------------------------------------------------------------------
// name : ClockProxy.cs
// project : Itenso Time Period
// created : Jani Giannoudis - 2011.02.18
// language : C# 4.0
// environment: .NET 2.0
// copyright : (c) 2011-2012 by Itenso GmbH, Switzerland
// --------------------------------------------------------------------------
namespace Itenso.TimePeriod
{
// ------------------------------------------------------------------------
public static class ClockProxy
{
// ----------------------------------------------------------------------
public static IClock Clock
{
get
{
if ( clock == null )
{
lock ( mutex )
{
if ( clock == null )
{
clock = new SystemClock();
}
}
}
return clock;
}
set
{
lock ( mutex )
{
clock = value;
}
}
} // Clock
// ----------------------------------------------------------------------
// members
private static readonly object mutex = new object();
private static volatile IClock clock;
} // class ClockProxy
} // namespace Itenso.TimePeriod
// -- EOF -------------------------------------------------------------------