aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/Util
diff options
context:
space:
mode:
Diffstat (limited to 'Firestore/Source/Util')
-rw-r--r--Firestore/Source/Util/FSTDispatchQueue.h26
-rw-r--r--Firestore/Source/Util/FSTDispatchQueue.mm4
2 files changed, 27 insertions, 3 deletions
diff --git a/Firestore/Source/Util/FSTDispatchQueue.h b/Firestore/Source/Util/FSTDispatchQueue.h
index 9b28c9c..7922600 100644
--- a/Firestore/Source/Util/FSTDispatchQueue.h
+++ b/Firestore/Source/Util/FSTDispatchQueue.h
@@ -23,11 +23,24 @@ NS_ASSUME_NONNULL_BEGIN
* can then be used from tests to check for the presence of callbacks or to run them early.
*/
typedef NS_ENUM(NSInteger, FSTTimerID) {
- FSTTimerIDAll, // Sentinel value to be used with runDelayedCallbacksUntil: to run all blocks.
+ /** All can be used with runDelayedCallbacksUntil: to run all timers. */
+ FSTTimerIDAll,
+
+ /**
+ * The following 4 timers are used in FSTStream for the listen and write streams. The "Idle" timer
+ * is used to close the stream due to inactivity. The "ConnectionBackoff" timer is used to
+ * restart a stream once the appropriate backoff delay has elapsed.
+ */
FSTTimerIDListenStreamIdle,
- FSTTimerIDListenStreamConnection,
+ FSTTimerIDListenStreamConnectionBackoff,
FSTTimerIDWriteStreamIdle,
- FSTTimerIDWriteStreamConnection
+ FSTTimerIDWriteStreamConnectionBackoff,
+
+ /**
+ * A timer used in FSTOnlineStateTracker to transition from FSTOnlineState Unknown to Offline
+ * after a set timeout, rather than waiting indefinitely for success or failure.
+ */
+ FSTTimerIDOnlineStateTimeout
};
/**
@@ -81,6 +94,13 @@ typedef NS_ENUM(NSInteger, FSTTimerID) {
- (void)dispatchAsyncAllowingSameQueue:(void (^)(void))block;
/**
+ * Wrapper for dispatch_sync(). Mostly meant for use in tests.
+ *
+ * @param block The block to run.
+ */
+- (void)dispatchSync:(void (^)(void))block;
+
+/**
* Schedules a callback after the specified delay.
*
* Unlike dispatchAsync: this method does not require you to dispatch to a different queue than
diff --git a/Firestore/Source/Util/FSTDispatchQueue.mm b/Firestore/Source/Util/FSTDispatchQueue.mm
index 5bd7f27..3184d29 100644
--- a/Firestore/Source/Util/FSTDispatchQueue.mm
+++ b/Firestore/Source/Util/FSTDispatchQueue.mm
@@ -187,6 +187,10 @@ NS_ASSUME_NONNULL_BEGIN
dispatch_async(self.queue, block);
}
+- (void)dispatchSync:(void (^)(void))block {
+ dispatch_sync(self.queue, block);
+}
+
- (FSTDelayedCallback *)dispatchAfterDelay:(NSTimeInterval)delay
timerID:(FSTTimerID)timerID
block:(void (^)(void))block {