IDEA-26360 (Performance and inconsistency issues with svn:externals and "Detect neste...
[fedora-idea.git] / plugins / svn4idea / src / org / jetbrains / idea / svn / DefendedCopiesRefreshProxy.java
blobb1614deecdde2ddccf451aef490d124e4ccd740b
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.jetbrains.idea.svn;
18 public class DefendedCopiesRefreshProxy implements CopiesRefresh {
19 private final ReentranceDefence myDefence;
21 private final MyEnsureInit myEnsureInit;
22 private final MyAsynchRequest myAsynchRequest;
23 private final MySynchRequest mySynchRequest;
25 public DefendedCopiesRefreshProxy(final CopiesRefresh refresh) {
26 myDefence = new ReentranceDefence();
28 myEnsureInit = new MyEnsureInit(refresh);
29 myAsynchRequest = new MyAsynchRequest(refresh);
30 mySynchRequest = new MySynchRequest(refresh);
33 public void ensureInit() {
34 ReentranceDefence.executeReentrant(myDefence, myEnsureInit);
37 public void asynchRequest() {
38 ReentranceDefence.executeReentrant(myDefence, myAsynchRequest);
41 public void synchRequest() {
42 ReentranceDefence.executeReentrant(myDefence, mySynchRequest);
45 public Runnable proxyRefresher(final Runnable runnable) {
46 return new Runnable() {
47 public void run() {
48 myDefence.executeOtherDefended(runnable);
53 private static class MyAsynchRequest extends MyBase {
54 private MyAsynchRequest(final CopiesRefresh delegate) {
55 super(delegate);
58 public Boolean executeMe() {
59 myDelegate.asynchRequest();
60 return null;
64 private static class MySynchRequest extends MyBase {
65 private MySynchRequest(final CopiesRefresh delegate) {
66 super(delegate);
69 public Boolean executeMe() {
70 myDelegate.synchRequest();
71 return null;
75 private static class MyEnsureInit extends MyBase {
76 private MyEnsureInit(final CopiesRefresh delegate) {
77 super(delegate);
80 public Boolean executeMe() {
81 myDelegate.ensureInit();
82 return null;
86 private abstract static class MyBase implements ReentranceDefence.MyControlled<Boolean> {
87 protected final CopiesRefresh myDelegate;
89 protected MyBase(final CopiesRefresh delegate) {
90 myDelegate = delegate;
93 public Boolean executeMeSimple() {
94 return null;