aliyun-oss-react-native

OSSExecutor.h 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. /*!
  13. An object that can run a given block.
  14. */
  15. @interface OSSExecutor : NSObject
  16. /*!
  17. Returns a default executor, which runs continuations immediately until the call stack gets too
  18. deep, then dispatches to a new GCD queue.
  19. */
  20. + (instancetype)defaultExecutor;
  21. /*!
  22. Returns an executor that runs continuations on the thread where the previous task was completed.
  23. */
  24. + (instancetype)immediateExecutor;
  25. /*!
  26. Returns an executor that runs continuations on the main thread.
  27. */
  28. + (instancetype)mainThreadExecutor;
  29. /*!
  30. Returns a new executor that uses the given block to execute continuations.
  31. @param block The block to use.
  32. */
  33. + (instancetype)executorWithBlock:(void(^)(void(^block)()))block;
  34. /*!
  35. Returns a new executor that runs continuations on the given queue.
  36. @param queue The instance of `dispatch_queue_t` to dispatch all continuations onto.
  37. */
  38. + (instancetype)executorWithDispatchQueue:(dispatch_queue_t)queue;
  39. /*!
  40. Returns a new executor that runs continuations on the given queue.
  41. @param queue The instance of `NSOperationQueue` to run all continuations on.
  42. */
  43. + (instancetype)executorWithOperationQueue:(NSOperationQueue *)queue;
  44. /*!
  45. Runs the given block using this executor's particular strategy.
  46. @param block The block to execute.
  47. */
  48. - (void)execute:(void(^)())block;
  49. @end
  50. NS_ASSUME_NONNULL_END