-
Notifications
You must be signed in to change notification settings - Fork 0
/
MutexInfo.cs
52 lines (45 loc) · 1.04 KB
/
MutexInfo.cs
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
52
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MemtexCS
{
public class MutexInfo
{
/// <summary>
/// The name of this networked Mutex
/// </summary>
public string Name;
/// <summary>
/// The time we acquired this mutex.
/// </summary>
public DateTime TimeAcquired;
/// <summary>
/// The total length of the mutex's lifetime; -1 for infinite.
/// </summary>
public long Lifetime;
/// <summary>
/// The UUID assigned to the Memtex instance
/// </summary>
public string ServerGUID;
/// <summary>
/// Used for safely releasing a mutex
/// </summary>
public ulong CasToken;
/// <summary>
/// True if we currently own this mutex
/// </summary>
public bool IsAcquired
{
get
{
return Attached && (((DateTime.Now - TimeAcquired).TotalMilliseconds < Lifetime) || Lifetime == -1);
}
}
/// <summary>
/// Internal tracking of whether we are maintaining this mutex.
/// </summary>
internal bool Attached;
}
}