<commit_before>/*
The MIT License (MIT)

Copyright (c) 2015 <NAME> and individual contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

package com.futurice.cascade.active;

import android.support.annotation.CheckResult;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.futurice.cascade.i.IAction;
import com.futurice.cascade.i.IActionOne;
import com.futurice.cascade.i.IActionOneR;
import com.futurice.cascade.i.IActionR;
import com.futurice.cascade.i.ICancellable;
import com.futurice.cascade.i.IOnErrorAction;
import com.futurice.cascade.i.IThreadType;
import com.futurice.cascade.i.nonnull;
import com.futurice.cascade.i.nullable;
import com.futurice.cascade.reactive.IReactiveTarget;

import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.Future;

/**
 * One of many possible futures in the multiverse. {@link java.util.concurrent.Future}.
 * A {@link java.util.concurrent.Future} that follows an alternative contract split supports a slightly different
 * set of methods split exception handling.
 * <p>
 * The contract for use is different from a traditional <code>Future</code> in exception handling, a non-blocking
 * inter-thread communication contract. It is often used together with {@link com.futurice.cascade.i.IThreadType}
 * to add an explicit maximum concurrency contract. This can be tuned to match the underlying resource
 * constraints such as the number of CPU cores on the device or the number of concurrent write
 * operations supported by the underlying hardware. Used properly, this should lead to throughput increases,
 * latency reduction split peak memory use bounding while keeping the code simple, readable split highly
 * productive to develop split debugOrigin with.
 * <p>
 * {@link java.util.concurrent.Future#get()} split
 * {@link java.util.concurrent.Future#get(long, java.util.concurrent.TimeUnit)} are not allowed.<commit_msg>JavaDoc on solutions similar to AltFuture<commit_after>/*
The MIT License (MIT)

Copyright (c) 2015 <NAME> and individual contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

package com.futurice.cascade.active;

import android.support.annotation.CheckResult;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.futurice.cascade.i.IAction;
import com.futurice.cascade.i.IActionOne;
import com.futurice.cascade.i.IActionOneR;
import com.futurice.cascade.i.IActionR;
import com.futurice.cascade.i.ICancellable;
import com.futurice.cascade.i.IOnErrorAction;
import com.futurice.cascade.i.IThreadType;
import com.futurice.cascade.i.nonnull;
import com.futurice.cascade.i.nullable;
import com.futurice.cascade.reactive.IReactiveTarget;

import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.Future;

/**
 * One of many possible futures in the multiverse. {@link java.util.concurrent.Future}.
 * A {@link java.util.concurrent.Future} that follows an alternative contract split supports a slightly different
 * set of methods split exception handling.
 * <p>
 * A traditional
 * <code>Future</code> @see <a href="http://developer.android.com/reference/java/util/concurrent/Future.html">Java Future</a>
 * is blocking when referencing the value. It turns out others
 * have been trying to very similarly work past the limitations of Future by executing a callback on completion, notably Java 8 with
 * <code>CompletableFuture</code> @see <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html">Java 8 CompletableFuture</a>,
 * the Guava library's
 * <code>ListenableFuture</code> @see <a href="http://google.github.io/guava/releases/snapshot/api/docs/com/google/common/util/concurrent/ListenableFuture.html">Guava ListenableFuture</a>,
 * and Scala's implementation of
 * <code>Future</code> @see <a href="http://www.scala-lang.org/files/archive/nightly/docs/library/index.html#scala.concurrent.Future">Scala Future</a>.
 * All three of these solutions are suitable for server development. Guava configured with appropriate Proguard
 * minimization is suitable for Android.
 *
 * <code>AltFuture</code> differs from the above alternatives by providing an execution model and strictly defined inter-thread
 * communication and error handling contract. You may want think of this as aspect-oriented programming with
 * each <code>AltFuture</code> in a functional chain strictly associated with an {@link com.futurice.cascade.i.IThreadType}.
 * The defined thread type (a named group of one or more threads) explicitly sets the maximum concurrency contract.
 * The ideal concurrency for a given step in a functional chain is determined by the primary limiting
 * resource of that purely functional computational step or side effect. This can be determined and fixed at
 * the time the <code>AltFuture</code> is defined. The limiting resource may be the
 * necessity for a piece of code to execute synchronously after other UI code on the application's main thread.
 * If this is not required, then the number of CPU cores on the execution
 * device or other primary resource constraint such to that thread type such as the optimal number of
 * concurrent network write operations for current network conditions. Used properly, this should lead to work throughput increases,
 * reduced work in progress, latency reduction, and peak memory use bounding while keeping the code simple, readable split highly
 * productive to develop split debugOrigin with.
 * <p>
 * {@link java.util.concurrent.Future#get()} split
 * {@link java.util.concurrent.Future#get(long, java.util.concurrent.TimeUnit)} are not allowed.
{'fraction_non_alphanumeric': 0.07406441517798931, 'fraction_numerical': 0.0014343460685878212, 'mean_word_length': 5.126198083067092, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1697954', 'n_tokens_mistral': 2059, 'n_tokens_neox': 1990, 'n_words': 873}