@@ -37,7 +37,6 @@ namespace FIREBASE_NAMESPACE {
37
37
// / @cond FIREBASE_APP_INTERNAL
38
38
namespace detail {
39
39
class FutureApiInterface ;
40
- class CompletionCallbackHandle ;
41
40
} // namespace detail
42
41
// / @endcond
43
42
@@ -85,12 +84,6 @@ class FutureBase {
85
84
typedef void (*CompletionCallback)(const FutureBase& result_data,
86
85
void * user_data);
87
86
88
- #if defined(INTERNAL_EXPERIMENTAL)
89
- // / Handle, representing a completion callback, that can be passed to
90
- // / RemoveOnCompletion.
91
- using CompletionCallbackHandle = detail::CompletionCallbackHandle;
92
- #endif
93
-
94
87
// / Construct an untyped future.
95
88
FutureBase ();
96
89
@@ -146,113 +139,34 @@ class FutureBase {
146
139
// / pending. Cast is required since GetFutureResult() returns void*.
147
140
const void * result_void () const ;
148
141
149
- // / Register a single callback that will be called at most once, when the
150
- // / future is completed.
151
- // /
152
- // / If you call any OnCompletion() method more than once on the same future,
153
- // / only the most recent callback you registered with OnCompletion() will be
154
- // / called.
155
- #if defined(INTERNAL_EXPERIMENTAL)
156
- // / However completions registered with AddCompletion() will still be
157
- // / called even if there is a subsequent call to OnCompletion().
142
+ // / Register a callback that will be called at most once, when the future is
143
+ // / completed.
158
144
// /
159
- // / When the future completes, first the most recent callback registered with
160
- // / OnCompletion(), if any, will be called; then all callbacks registered with
161
- // / AddCompletion() will be called, in the order that they were registered.
162
- #endif
145
+ // / If you call any OnCompletion() method more than once, only the most recent
146
+ // / callback you registered will be called.
163
147
// /
164
148
// / When your callback is called, the user_data that you supplied here will be
165
149
// / passed back as the second parameter.
166
150
// /
167
151
// / @param[in] callback Function pointer to your callback.
168
152
// / @param[in] user_data Optional user data. We will pass this back to your
169
153
// / callback.
170
- #if defined(INTERNAL_EXPERIMENTAL)
171
- // / @return A handle that can be passed to RemoveOnCompletion.
172
- CompletionCallbackHandle
173
- #else
174
- void
175
- #endif
176
- OnCompletion (CompletionCallback callback, void * user_data) const ;
177
-
178
- #if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
179
- // / Register a single callback that will be called at most once, when the
180
- // / future is completed.
181
- // /
182
- // / If you call any OnCompletion() method more than once on the same future,
183
- // / only the most recent callback you registered with OnCompletion() will be
184
- // / called.
185
- #if defined(INTERNAL_EXPERIMENTAL)
186
- // / However completions registered with AddCompletion() will still be
187
- // / called even if there is a subsequent call to OnCompletion().
188
- // /
189
- // / When the future completes, first the most recent callback registered with
190
- // / OnCompletion(), if any, will be called; then all callbacks registered with
191
- // / AddCompletion() will be called, in the order that they were registered.
192
- #endif
193
- // /
194
- // / @param[in] callback Function or lambda to call.
195
- // /
196
- // / @note This method is not available when using STLPort on Android, as
197
- // / `std::function` is not supported on STLPort.
198
- #if defined(INTERNAL_EXPERIMENTAL)
199
- // / @return A handle that can be passed to RemoveOnCompletion.
200
- CompletionCallbackHandle
201
- #else
202
- void
203
- #endif
204
- OnCompletion (std::function<void (const FutureBase&)> callback) const ;
205
- #endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
206
-
207
- #if defined(INTERNAL_EXPERIMENTAL)
208
- // / Like OnCompletion, but allows adding multiple callbacks.
209
- // /
210
- // / If you call AddCompletion() more than once, all of the completions that
211
- // / you register will be called, when the future is completed. However, any
212
- // / callbacks which were subsequently removed by calling RemoveOnCompletion
213
- // / will not be called.
214
- // /
215
- // / When the future completes, first the most recent callback registered with
216
- // / OnCompletion(), if any, will be called; then all callbacks registered with
217
- // / AddCompletion() will be called, in the order that they were registered.
218
- // /
219
- // / @param[in] callback Function pointer to your callback.
220
- // / @param[in] user_data Optional user data. We will pass this back to your
221
- // / callback.
222
- // / @return A handle that can be passed to RemoveOnCompletion.
223
- CompletionCallbackHandle
224
- AddOnCompletion (CompletionCallback callback, void * user_data) const ;
154
+ void OnCompletion (CompletionCallback callback, void * user_data) const ;
225
155
226
156
#if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
227
- // / Like OnCompletion, but allows adding multiple callbacks.
157
+ // / Register a callback that will be called at most once, when the future is
158
+ // / completed.
228
159
// /
229
- // / If you call AddCompletion() more than once, all of the completions that
230
- // / you register will be called, when the future is completed. However, any
231
- // / callbacks which were subsequently removed by calling RemoveOnCompletion
232
- // / will not be called.
233
- // /
234
- // / When the future completes, first the most recent callback registered with
235
- // / OnCompletion(), if any, will be called; then all callbacks registered with
236
- // / AddCompletion() will be called, in the order that they were registered.
160
+ // / If you call any OnCompletion() method more than once, only the most recent
161
+ // / callback you registered will be called.
237
162
// /
238
163
// / @param[in] callback Function or lambda to call.
239
- // / @return A handle that can be passed to RemoveOnCompletion.
240
164
// /
241
165
// / @note This method is not available when using STLPort on Android, as
242
166
// / `std::function` is not supported on STLPort.
243
- CompletionCallbackHandle AddOnCompletion (
244
- std::function<void (const FutureBase&)> callback) const ;
245
-
167
+ void OnCompletion (std::function<void (const FutureBase&)> callback) const ;
246
168
#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
247
169
248
- // / Unregisters a callback that was previously registered with
249
- // / AddOnCompletion or OnCompletion.
250
- // /
251
- // / @param[in] completion_handle The return value of a previous call to
252
- // / AddOnCompletion or OnCompletion.
253
- void RemoveOnCompletion (CompletionCallbackHandle completion_handle) const ;
254
- #endif // defined(INTERNAL_EXPERIMENTAL)
255
-
256
170
// / Returns true if the two Futures reference the same result.
257
171
bool operator ==(const FutureBase& rhs) const {
258
172
return api_ == rhs.api_ && handle_ == rhs.handle_ ;
@@ -368,11 +282,11 @@ class Future : public FutureBase {
368
282
return static_cast <const ResultType*>(result_void ());
369
283
}
370
284
371
- // / Register a single callback that will be called at most once, when the
372
- // / future is completed.
285
+ // / Register a callback that will be called at most once, when the future is
286
+ // / completed.
373
287
// /
374
- // / If you call any OnCompletion() method more than once on the same future,
375
- // / only the most recent callback you registered will be called.
288
+ // / If you call any OnCompletion() method more than once, only the most recent
289
+ // / callback you registered will be called.
376
290
// /
377
291
// / When your callback is called, the user_data that you supplied here will be
378
292
// / passed back as the second parameter.
@@ -384,20 +298,17 @@ class Future : public FutureBase {
384
298
// / @note This is the same callback as FutureBase::OnCompletion(), so you
385
299
// / can't expect to set both and have both run; again, only the most recently
386
300
// / registered one will run.
387
- #if defined(INTERNAL_EXPERIMENTAL)
388
- // / @return A handle that can be passed to RemoveOnCompletion.
389
- inline CompletionCallbackHandle
390
- #else
391
- inline void
392
- #endif
393
- OnCompletion (TypedCompletionCallback callback, void * user_data) const ;
301
+ void OnCompletion (TypedCompletionCallback callback, void * user_data) const {
302
+ FutureBase::OnCompletion (reinterpret_cast <CompletionCallback>(callback),
303
+ user_data);
304
+ }
394
305
395
306
#if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
396
- // / Register a single callback that will be called at most once, when the
397
- // / future is completed.
307
+ // / Register a callback that will be called at most once, when the future is
308
+ // / completed.
398
309
// /
399
- // / If you call any OnCompletion() method more than once on the same future,
400
- // / only the most recent callback you registered will be called.
310
+ // / If you call any OnCompletion() method more than once, only the most recent
311
+ // / callback you registered will be called.
401
312
// /
402
313
// / @param[in] callback Function or lambda to call.
403
314
// /
@@ -407,56 +318,12 @@ class Future : public FutureBase {
407
318
// / @note This is the same callback as FutureBase::OnCompletion(), so you
408
319
// / can't expect to set both and have both run; again, only the most recently
409
320
// / registered one will run.
410
- #if defined(INTERNAL_EXPERIMENTAL)
411
- // / @return A handle that can be passed to RemoveOnCompletion.
412
- inline CompletionCallbackHandle
413
- #else
414
- inline void
415
- #endif
416
- OnCompletion (std::function<void (const Future<ResultType>&)> callback) const ;
417
- #endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
418
-
419
- #if defined(INTERNAL_EXPERIMENTAL)
420
- // / Like OnCompletion, but allows adding multiple callbacks.
421
- // /
422
- // / If you call AddCompletion() more than once, all of the completions that
423
- // / you register will be called, when the future is completed. However, any
424
- // / callbacks which were subsequently removed by calling RemoveOnCompletion
425
- // / will not be called.
426
- // /
427
- // / When the future completes, first the most recent callback registered with
428
- // / OnCompletion(), if any, will be called; then all callbacks registered with
429
- // / AddCompletion() will be called, in the order that they were registered.
430
- // /
431
- // / @param[in] callback Function pointer to your callback.
432
- // / @param[in] user_data Optional user data. We will pass this back to your
433
- // / callback.
434
- // / @return A handle that can be passed to RemoveOnCompletion.
435
- inline CompletionCallbackHandle
436
- AddOnCompletion (TypedCompletionCallback callback, void * user_data) const ;
437
-
438
- #if defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
439
- // / Like OnCompletion, but allows adding multiple callbacks.
440
- // /
441
- // / If you call AddCompletion() more than once, all of the completions that
442
- // / you register will be called, when the future is completed. However, any
443
- // / callbacks which were subsequently removed by calling RemoveOnCompletion
444
- // / will not be called.
445
- // /
446
- // / When the future completes, first the most recent callback registered with
447
- // / OnCompletion(), if any, will be called; then all callbacks registered with
448
- // / AddCompletion() will be called, in the order that they were registered.
449
- // /
450
- // / @param[in] callback Function or lambda to call.
451
- // / @return A handle that can be passed to RemoveOnCompletion.
452
- // /
453
- // / @note This method is not available when using STLPort on Android, as
454
- // / `std::function` is not supported on STLPort.
455
- inline CompletionCallbackHandle
456
- AddOnCompletion (std::function<void (const Future<ResultType>&)> callback)
457
- const ;
321
+ void OnCompletion (
322
+ std::function<void (const Future<ResultType>&)> callback) const {
323
+ FutureBase::OnCompletion (
324
+ *reinterpret_cast <std::function<void (const FutureBase&)>*>(&callback));
325
+ }
458
326
#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
459
- #endif // defined(INTERNAL_EXPERIMENTAL)
460
327
};
461
328
462
329
// NOLINTNEXTLINE - allow namespace overridden
0 commit comments