VCS: allow Git to report changed on server files comparing the whole tree. !! require...
[fedora-idea.git] / plugins / svn4idea / src / org / jetbrains / idea / svn / ReentranceDefence.java
blob864f962916be9b0d96b4daa7e9b1d3362c2f93dd
1 package org.jetbrains.idea.svn;
3 public class ReentranceDefence {
4 protected final ThreadLocal<Boolean> myThreadLocal;
6 protected ReentranceDefence() {
7 myThreadLocal = new ThreadLocal<Boolean>() {
8 @Override
9 protected Boolean initialValue() {
10 return Boolean.TRUE;
15 public static <T> T executeReentrant(final ReentranceDefence defence, final MyControlled<T> controlled) {
16 if (defence.isInside()) {
17 return controlled.executeMeSimple();
19 return controlled.executeMe();
22 public boolean isInside() {
23 return ! Boolean.TRUE.equals(myThreadLocal.get());
26 public boolean isOutside() {
27 return ! isInside();
30 public void executeOtherDefended(final Runnable runnable) {
31 try {
32 myThreadLocal.set(Boolean.FALSE);
33 runnable.run();
34 } finally {
35 myThreadLocal.set(Boolean.TRUE);
39 public interface MyControlled<T> {
40 T executeMe();
41 T executeMeSimple();