// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
//     R call(T input);
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
//     S call(T input1, R input2);
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
// 
//     private TaskListener<R, S> mListener;
// 
//     public Task() {
//     }
// 
//     public void setListener(TaskListener<R, S> listener) {
//         mListener = listener;
//     }
// 
//     protected abstract void onExecute(T input);
// 
//     public final void execute(T input) {
//         onExecute(input);
//     }
// 
//     public final void notifySuccess(R result) {
//         if (mListener != null) {
//             mListener.onSuccess(result);
//         }
//     }
// 
//     public final void notifyFailure(S error) {
//         if (mListener != null) {
//             mListener.onFailure(error);
//         }
//     }
// 
//     public interface TaskListener<R, S> {
//         void onSuccess(R result);
//         void onFailure(S error);
//     }
// 
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
//     public final T1 first;
//     public final T2 second;
//     public final T3 third;
// 
//     @Deprecated
//     public Triple(T1 first, T2 second, T3 third) {
//         this.first = first;
//         this.second = second;
//         this.third = third;
//     }
// 
//     public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
//         return new Triple<T1, T2, T3>(first, second, third);
//     }
// }


import xiaofei.library.concurrentutils.ObjectCanary;
import xiaofei.library.concurrentutils.util.Action;
import xiaofei.library.concurrentutils.util.Condition;
import xiaofei.library.concurrentutils.util.Function;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2;
import xiaofei.library.shelly.task.Task;
import xiaofei.library.shelly.tuple.Triple;
                    }
                }));
    }

    private static class ResultWrapper<T, R> {
        private volatile int mFlag;
        private volatile T mResult;
        private volatile R mError;

        ResultWrapper() {
            mFlag = -1;
            mResult = null;
            mError = null;
        }

        public void setError(R error) {
            mError = error;
            mFlag = 0;
        }

        public void setResult(T result) {
            mResult = result;
            mFlag = 1;
        }

        public R getError() {
            return mError;
        }

        public int getFlag() {
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function1.java
// public interface Function1<T, R> extends Function {
//     R call(T input);
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/function/Function2.java
// public interface Function2<T, R, S> extends Function {
//     S call(T input1, R input2);
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/task/Task.java
// public abstract class Task<T, R, S> {
// 
//     private TaskListener<R, S> mListener;
// 
//     public Task() {
//     }
// 
//     public void setListener(TaskListener<R, S> listener) {
//         mListener = listener;
//     }
// 
//     protected abstract void onExecute(T input);
// 
//     public final void execute(T input) {
//         onExecute(input);
//     }
// 
//     public final void notifySuccess(R result) {
//         if (mListener != null) {
//             mListener.onSuccess(result);
//         }
//     }
// 
//     public final void notifyFailure(S error) {
//         if (mListener != null) {
//             mListener.onFailure(error);
//         }
//     }
// 
//     public interface TaskListener<R, S> {
//         void onSuccess(R result);
//         void onFailure(S error);
//     }
// 
// }
// 
// Path: shelly/src/main/java/xiaofei/library/shelly/tuple/Triple.java
// public class Triple<T1, T2, T3> {
//     public final T1 first;
//     public final T2 second;
//     public final T3 third;
// 
//     @Deprecated
//     public Triple(T1 first, T2 second, T3 third) {
//         this.first = first;
//         this.second = second;
//         this.third = third;
//     }
// 
//     public static <T1, T2, T3> Triple<T1, T2, T3> create(T1 first, T2 second, T3 third) {
//         return new Triple<T1, T2, T3>(first, second, third);
//     }
// }


// Path: shelly/src/main/java/xiaofei/library/shelly/util/TaskFunction.java
import xiaofei.library.concurrentutils.ObjectCanary;
import xiaofei.library.concurrentutils.util.Action;
import xiaofei.library.concurrentutils.util.Condition;
import xiaofei.library.concurrentutils.util.Function;
import xiaofei.library.shelly.function.Function1;
import xiaofei.library.shelly.function.Function2;
import xiaofei.library.shelly.task.Task;
import xiaofei.library.shelly.tuple.Triple;

                    }
                }));
    }

    private static class ResultWrapper<T, R> {
        private volatile int mFlag;
        private volatile T mResult;
        private volatile R mError;

        ResultWrapper() {
            mFlag = -1;
            mResult = null;
            mError = null;
        }

        public void setError(R error) {
            mError = error;
            mFlag = 0;
        }

        public void setResult(T result) {
            mResult = result;
            mFlag = 1;
        }

        public R getError() {
            return mError;
        }

        public int getFlag() {
            return mFlag;