aliyun-oss-react-native

OSSCancellationTokenSource.h 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2014, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #import <Foundation/Foundation.h>
  11. NS_ASSUME_NONNULL_BEGIN
  12. @class OSSCancellationToken;
  13. /*!
  14. OSSCancellationTokenSource represents the producer side of a CancellationToken.
  15. Signals to a CancellationToken that it should be canceled.
  16. It is a cancellation token that also has methods
  17. for changing the state of a token by cancelling it.
  18. */
  19. @interface OSSCancellationTokenSource : NSObject
  20. /*!
  21. Creates a new cancellation token source.
  22. */
  23. + (instancetype)cancellationTokenSource;
  24. /*!
  25. The cancellation token associated with this CancellationTokenSource.
  26. */
  27. @property (nonatomic, strong, readonly) OSSCancellationToken *token;
  28. /*!
  29. Whether cancellation has been requested for this token source.
  30. */
  31. @property (nonatomic, assign, readonly, getter=isCancellationRequested) BOOL cancellationRequested;
  32. /*!
  33. Cancels the token if it has not already been cancelled.
  34. */
  35. - (void)cancel;
  36. /*!
  37. Schedules a cancel operation on this CancellationTokenSource after the specified number of milliseconds.
  38. @param millis The number of milliseconds to wait before completing the returned task.
  39. If delay is `0` the cancel is executed immediately. If delay is `-1` any scheduled cancellation is stopped.
  40. */
  41. - (void)cancelAfterDelay:(int)millis;
  42. /*!
  43. Releases all resources associated with this token source,
  44. including disposing of all registrations.
  45. */
  46. - (void)dispose;
  47. @end
  48. NS_ASSUME_NONNULL_END