// Path: buruberi-core/src/main/java/is/hello/buruberi/bluetooth/stacks/OperationTimeout.java
// public interface OperationTimeout {
//     String LOG_TAG = "Bluetooth." + OperationTimeout.class.getSimpleName();
// 
//     /**
//      * Called by {@link GattPeripheral}. Schedules a timeout timer.
//      * <p>
//      * This method is not assumed to be safe to call until after
//      * {@link #setTimeoutAction(Action0, Scheduler)} is called.
//      */
//     void schedule();
// 
//     /**
//      * Called by {@link GattPeripheral}. Unschedules the timeout timer.
//      * <p>
//      * It is a valid condition for this method to be called multiple times,
//      * it should become a no-op after the first call.
//      * <p>
//      * This method is not assumed to be safe to call until after
//      * {@link #setTimeoutAction(Action0, Scheduler)} is called.
//      */
//     void unschedule();
// 
//     /**
//      * For use by clients. Unschedules and reschedules the timeout timer.
//      * <p>
//      * This method is not assumed to be safe to call until after
//      * {@link #setTimeoutAction(Action0, Scheduler)} is called.
//      */
//     void reschedule();
// 
//     /**
//      * Called by {@link GattPeripheral}. Specifies an action to run when
//      * the timeout expires that will allow the stack to clean up any resources.
//      * <p>
//      * Client code should check the state of a peripheral after a timeout has expired.
//      *
//      * @param action    Stack specific logic to handle the timeout.
//      * @param scheduler The scheduler to run the handler on.
//      */
//     void setTimeoutAction(@NonNull Action0 action, @NonNull Scheduler scheduler);
// }
// 
// Path: buruberi-core/src/main/java/is/hello/buruberi/bluetooth/stacks/util/LoggerFacade.java
// public interface LoggerFacade {
//     void error(@NonNull String tag, @Nullable String message, @Nullable Throwable e);
//     void warn(@NonNull String tag, @Nullable String message, @Nullable Throwable e);
//     void warn(@NonNull String tag, @Nullable String message);
//     void info(@NonNull String tag, @Nullable String message);
//     void debug(@NonNull String tag, @Nullable String message);
// }


import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.concurrent.TimeUnit;
import is.hello.buruberi.bluetooth.stacks.OperationTimeout;
import is.hello.buruberi.bluetooth.stacks.util.LoggerFacade;
import rx.Scheduler;
import rx.Subscription;
import rx.functions.Action0;
/*
 * Copyright 2015 Hello Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
package is.hello.buruberi.bluetooth.stacks.android;




/**
 * Simple implementation of {@link OperationTimeout} that uses deferred workers.
 */
public final class SchedulerOperationTimeout implements OperationTimeout {
    private final String name;
    private final long durationMs;
// Path: buruberi-core/src/main/java/is/hello/buruberi/bluetooth/stacks/OperationTimeout.java
// public interface OperationTimeout {
//     String LOG_TAG = "Bluetooth." + OperationTimeout.class.getSimpleName();
// 
//     /**
//      * Called by {@link GattPeripheral}. Schedules a timeout timer.
//      * <p>
//      * This method is not assumed to be safe to call until after
//      * {@link #setTimeoutAction(Action0, Scheduler)} is called.
//      */
//     void schedule();
// 
//     /**
//      * Called by {@link GattPeripheral}. Unschedules the timeout timer.
//      * <p>
//      * It is a valid condition for this method to be called multiple times,
//      * it should become a no-op after the first call.
//      * <p>
//      * This method is not assumed to be safe to call until after
//      * {@link #setTimeoutAction(Action0, Scheduler)} is called.
//      */
//     void unschedule();
// 
//     /**
//      * For use by clients. Unschedules and reschedules the timeout timer.
//      * <p>
//      * This method is not assumed to be safe to call until after
//      * {@link #setTimeoutAction(Action0, Scheduler)} is called.
//      */
//     void reschedule();
// 
//     /**
//      * Called by {@link GattPeripheral}. Specifies an action to run when
//      * the timeout expires that will allow the stack to clean up any resources.
//      * <p>
//      * Client code should check the state of a peripheral after a timeout has expired.
//      *
//      * @param action    Stack specific logic to handle the timeout.
//      * @param scheduler The scheduler to run the handler on.
//      */
//     void setTimeoutAction(@NonNull Action0 action, @NonNull Scheduler scheduler);
// }
// 
// Path: buruberi-core/src/main/java/is/hello/buruberi/bluetooth/stacks/util/LoggerFacade.java
// public interface LoggerFacade {
//     void error(@NonNull String tag, @Nullable String message, @Nullable Throwable e);
//     void warn(@NonNull String tag, @Nullable String message, @Nullable Throwable e);
//     void warn(@NonNull String tag, @Nullable String message);
//     void info(@NonNull String tag, @Nullable String message);
//     void debug(@NonNull String tag, @Nullable String message);
// }


// Path: buruberi-core/src/main/java/is/hello/buruberi/bluetooth/stacks/android/SchedulerOperationTimeout.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.concurrent.TimeUnit;
import is.hello.buruberi.bluetooth.stacks.OperationTimeout;
import is.hello.buruberi.bluetooth.stacks.util.LoggerFacade;
import rx.Scheduler;
import rx.Subscription;
import rx.functions.Action0;

/*
 * Copyright 2015 Hello Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
package is.hello.buruberi.bluetooth.stacks.android;




/**
 * Simple implementation of {@link OperationTimeout} that uses deferred workers.
 */
public final class SchedulerOperationTimeout implements OperationTimeout {
    private final String name;
    private final long durationMs;
    private final LoggerFacade logger;