ALAtomicBoolean.h 1021 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // ALAtomicBoolean.h
  3. // AppLovinSDK
  4. //
  5. // Created by Thomas So on 3/5/17.
  6. //
  7. NS_ASSUME_NONNULL_BEGIN
  8. /**
  9. * A boolean value that may be updated atomically.
  10. *
  11. * NOTE: This class is used by our adapters (ironSource), do not change API.
  12. */
  13. @interface ALAtomicBoolean : NSObject
  14. /**
  15. * Returns the current value.
  16. */
  17. - (BOOL)get;
  18. /**
  19. * Unconditionally sets to the given value.
  20. */
  21. - (void)set:(BOOL)newValue;
  22. /**
  23. * Atomically sets to the given value and returns the previous value.
  24. */
  25. - (BOOL)getAndSet:(BOOL)newValue;
  26. /**
  27. * Atomically sets the value to the given updated value if the current value == the expected value.
  28. *
  29. * @param expect The expected value.
  30. * @param update The new value.
  31. *
  32. * @return YES if successful. NO return indicates that the actual value was not equal to the expected value.
  33. */
  34. - (BOOL)compareAndSet:(BOOL)expect update:(BOOL)update;
  35. /**
  36. * Creates an instance with the default BOOL value.
  37. */
  38. - (instancetype)initWithValue:(BOOL)initialValue;
  39. @end
  40. NS_ASSUME_NONNULL_END