No Description

AWSCancellationTokenSource.h 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 AWSCancellationToken;
  13. /*!
  14. AWSCancellationTokenSource 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 AWSCancellationTokenSource : 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) AWSCancellationToken *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