Formatted code.

Moved static members to top of class.
This commit is contained in:
Sipke Schoorstra
2015-08-22 17:51:34 +01:00
parent 079fb1f84b
commit 5dcbad2235

View File

@@ -7,23 +7,6 @@ namespace Orchard.Tasks.Locking.Services {
/// Represents a distributed lock. />
/// </summary>
public class DistributedLock : IDisposable {
private IDistributedLockService _service;
private int _isDisposed;
private DistributedLock() {
}
public string Id { get; private set; }
public string Name { get; private set; }
public string MachineName { get; private set; }
public int? ThreadId { get; private set; }
// This will be called at least and at the latest by the IoC container when the request ends.
public void Dispose() {
if(Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
_service.ReleaseLock(this);
}
public static DistributedLock ForMachine(IDistributedLockService service, string name, string machineName, string lockId) {
return new DistributedLock {
_service = service,
@@ -42,5 +25,22 @@ namespace Orchard.Tasks.Locking.Services {
Id = lockId
};
}
private IDistributedLockService _service;
private int _isDisposed;
private DistributedLock() {
}
public string Id { get; private set; }
public string Name { get; private set; }
public string MachineName { get; private set; }
public int? ThreadId { get; private set; }
// This will be called at least and at the latest by the IoC container when the request ends.
public void Dispose() {
if(Interlocked.CompareExchange(ref _isDisposed, 1, 0) == 0)
_service.ReleaseLock(this);
}
}
}