tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
DmbLock.cs
Go to the documentation of this file.
1using System;
2using System.Threading.Tasks;
3
6
8{
12 sealed class DmbLock : IDmbProvider
13 {
15 public string DmbName => baseProvider.DmbName;
16
19
22
25
29 public Guid LockID { get; }
30
34 public DateTimeOffset LockTime { get; }
35
39 public string Descriptor { get; }
40
44 public bool KeptAlive { get; private set; }
45
50
54 readonly Func<ValueTask> disposeAction;
55
62 public DmbLock(Func<ValueTask> disposeAction, IDmbProvider baseProvider, string descriptor)
63 {
64 this.disposeAction = disposeAction ?? throw new ArgumentNullException(nameof(disposeAction));
65 this.baseProvider = baseProvider ?? throw new ArgumentNullException(nameof(baseProvider));
66 Descriptor = descriptor ?? throw new ArgumentNullException(nameof(descriptor));
67
68 LockID = Guid.NewGuid();
69 LockTime = DateTimeOffset.UtcNow;
70 }
71
73 public ValueTask DisposeAsync() => disposeAction();
74
76 public void KeepAlive()
77 {
78 KeptAlive = true;
80 }
81 }
82}
Information about an engine installation.
Represents a lock on a given IDmbProvider.
Definition DmbLock.cs:13
readonly Func< ValueTask > disposeAction
A Func<TResult> to use as the implementation of DisposeAsync.
Definition DmbLock.cs:54
string Descriptor
A description of the DmbLock's purpose.
Definition DmbLock.cs:39
string Directory
The primary game directory.
Definition DmbLock.cs:18
DmbLock(Func< ValueTask > disposeAction, IDmbProvider baseProvider, string descriptor)
Initializes a new instance of the DmbLock class.
Definition DmbLock.cs:62
DateTimeOffset LockTime
The DateTimeOffset of when the lock was acquired.
Definition DmbLock.cs:34
readonly IDmbProvider baseProvider
The IDmbProvider being wrapped.
Definition DmbLock.cs:49
string DmbName
The file name of the .dmb.
Definition DmbLock.cs:15
void KeepAlive()
Disposing the IDmbProvider won't cause a cleanup of the working directory.
Definition DmbLock.cs:76
bool KeptAlive
If KeepAlive was called on the DmbLock.
Definition DmbLock.cs:44
Provides absolute paths to the latest compiled .dmbs.
void KeepAlive()
Disposing the IDmbProvider won't cause a cleanup of the working directory.
EngineVersion EngineVersion
The Api.Models.EngineVersion used to build the .dmb.
Models.CompileJob CompileJob
The CompileJob of the .dmb.