Browse Source

Minor tweak to organization of CommitTransaction

4.0.0-beta
Anairkoen Schno 4 years ago
parent
commit
bb16807656
1 changed files with 4 additions and 8 deletions
  1. +4
    -8
      IPA.Loader/Loader/PluginManager.cs

+ 4
- 8
IPA.Loader/Loader/PluginManager.cs View File

@ -81,19 +81,15 @@ namespace IPA.Loader
internal static Task CommitTransaction(StateTransitionTransaction transaction) internal static Task CommitTransaction(StateTransitionTransaction transaction)
{ {
if (UnityGame.OnMainThread)
return CommitTransactionInternal(transaction);
else
return UnityMainThreadTaskScheduler.Factory.StartNew(() => CommitTransactionInternal(transaction)).Unwrap();
}
private static Task CommitTransactionInternal(StateTransitionTransaction transaction)
{
if (!UnityGame.OnMainThread)
return UnityMainThreadTaskScheduler.Factory.StartNew(() => CommitTransaction(transaction)).Unwrap();
lock (commitTransactionLockObject) lock (commitTransactionLockObject)
{ {
if (transaction.CurrentlyEnabled.Except(AllPlugins) if (transaction.CurrentlyEnabled.Except(AllPlugins)
.Concat(AllPlugins.Except(transaction.CurrentlyEnabled)).Any() .Concat(AllPlugins.Except(transaction.CurrentlyEnabled)).Any()
|| transaction.CurrentlyDisabled.Except(DisabledPlugins) || transaction.CurrentlyDisabled.Except(DisabledPlugins)
.Concat(DisabledPlugins.Except(transaction.DisabledPlugins)).Any())
.Concat(DisabledPlugins.Except(transaction.CurrentlyDisabled)).Any())
{ // ensure that the transaction's base state reflects the current state, otherwise throw { // ensure that the transaction's base state reflects the current state, otherwise throw
throw new InvalidOperationException("Transaction no longer resembles the current state of plugins"); throw new InvalidOperationException("Transaction no longer resembles the current state of plugins");
} }


Loading…
Cancel
Save