Beispiel #1
0
 public void LeavePlanetExclusive(PlanetExclusiveOperation op)
 {
     if (op == CurrentPlanetExclusiveOperation)
     {
         op.Dispose();
     }
     else
     {
         throw new ArgumentException("Invalid planet exclusive token!");
     }
 }
Beispiel #2
0
 public IDisposable EnterPlanetExclusive(IPlanetExclusiveOperation operation)
 {
     Monitor.Enter(_lockPlanetExclusive);
     // if the same thread entered here, but invoked an exlusive planet operation for a different planet, it's an error!
     if (CurrentPlanetExclusiveOperation != null)
     {
         // the same planet id, it's all fine, we don't need a new lock because the existing one is still there
         if (CurrentPlanetExclusiveOperation.Operation.PlanetId == operation.PlanetId)
         {
             Monitor.Exit(_lockPlanetExclusive);
             return(null);
         }
         else
         {
             Logger.Instance.Log(LogLevel.Error, $"Current planet exclusive is not released!!! Current: {CurrentPlanetExclusiveOperation.Operation.Name}, new: {operation.Name}.");
         }
     }
     CurrentPlanetExclusiveOperation = new PlanetExclusiveOperation(this, operation);
     return(CurrentPlanetExclusiveOperation);
 }