public void runWriteAction(@NotNull final Runnable action) {
   final AccessToken token = acquireWriteActionLock(action.getClass());
   try {
     action.run();
   } finally {
     token.finish();
   }
 }
Exemplo n.º 2
0
  public <T> T getCurrentWriteAction(@Nullable Class<T> actionClass) {
    assertCanRunWriteAction();

    for (int i = myWriteActionsStack.size() - 1; i >= 0; i--) {
      Runnable action = myWriteActionsStack.get(i);
      if (actionClass == null || ReflectionCache.isAssignable(actionClass, action.getClass()))
        return (T) action;
    }
    return null;
  }