mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Formatted code.
Moved static members to top of class.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user