blob: 1a8e29fb01466e9f307ae00fcdf0024392082ae8 [file] [log] [blame]
Andrew Brown6e002952016-09-12 20:36:45 -07001/*
2 * jndn-utils
3 * Copyright (c) 2016, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU Lesser General Public License,
7 * version 3, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT ANY
10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
12 * more details.
13 */
14
15package com.intel.jndn.utils;
16
17/**
18 * Represents a token used for canceling some ongoing action. This approach was chosen as it is lighter and more
19 * flexible than a cancellable {@link java.util.concurrent.Future}; perhaps it could be replaced by {@link
20 * AutoCloseable} although this seems to imply something else (however, the language support is a benefit, TODO
21 * re-look at this).
22 *
23 * @author Andrew Brown, andrew.brown@intel.com
24 */
25public interface Cancellation {
26 /**
27 * Shortcut for a no-op, already-cancelled cancellation
28 */
29 Cancellation CANCELLED = () -> {/* do nothing */};
30
31 /**
32 * Cancel the action referenced by this token
33 */
34 void cancel();
35}