aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/Util/FSTAsyncQueryListener.mm
diff options
context:
space:
mode:
authorGravatar Konstantin Varlamov <var-const@users.noreply.github.com>2018-05-10 20:16:50 -0400
committerGravatar GitHub <noreply@github.com>2018-05-10 20:16:50 -0400
commitedd6f60a7385f9280c371df273703f6e104e325f (patch)
tree89b2d18d4f5d4253dd6b87842d7a0182aabd50de /Firestore/Source/Util/FSTAsyncQueryListener.mm
parent8cde81689dcfc74c9b59e088bbe00f95ca4bf68d (diff)
Firestore: use C++ Executor for user queue. (#1238)
FSTDispatchQueue enforces serial execution, which is inappropriate for user queue, because a user may configure usage of a concurrent queue in settings, breaking FSTDispatchQueue invariants. Instead, use C++ ExecutorLibdispatch directly.
Diffstat (limited to 'Firestore/Source/Util/FSTAsyncQueryListener.mm')
-rw-r--r--Firestore/Source/Util/FSTAsyncQueryListener.mm14
1 files changed, 8 insertions, 6 deletions
diff --git a/Firestore/Source/Util/FSTAsyncQueryListener.mm b/Firestore/Source/Util/FSTAsyncQueryListener.mm
index b72ac57..426594b 100644
--- a/Firestore/Source/Util/FSTAsyncQueryListener.mm
+++ b/Firestore/Source/Util/FSTAsyncQueryListener.mm
@@ -18,16 +18,18 @@
#import "Firestore/Source/Util/FSTDispatchQueue.h"
+using firebase::firestore::util::internal::Executor;
+
@implementation FSTAsyncQueryListener {
volatile BOOL _muted;
FSTViewSnapshotHandler _snapshotHandler;
- FSTDispatchQueue *_dispatchQueue;
+ Executor *_executor;
}
-- (instancetype)initWithDispatchQueue:(FSTDispatchQueue *)dispatchQueue
- snapshotHandler:(FSTViewSnapshotHandler)snapshotHandler {
+- (instancetype)initWithExecutor:(Executor *)executor
+ snapshotHandler:(FSTViewSnapshotHandler)snapshotHandler {
if (self = [super init]) {
- _dispatchQueue = dispatchQueue;
+ _executor = executor;
_snapshotHandler = snapshotHandler;
}
return self;
@@ -40,11 +42,11 @@
// users just want to turn on notifications "forever" and don't want to have
// to keep track of our handle to keep them going.
return ^(FSTViewSnapshot *_Nullable snapshot, NSError *_Nullable error) {
- [self->_dispatchQueue dispatchAsync:^{
+ _executor->Execute([self, snapshot, error] {
if (!self->_muted) {
self->_snapshotHandler(snapshot, error);
}
- }];
+ });
};
}