Skip to content

Commit 5114ea9

Browse files
markchandlera-maurice
markchandler
authored andcommitted
Automated g4 rollback of changelist 267398802.
*** Reason for rollback *** Fails to compile on gLinux via cmake. Can test a fix via: mkdir /tmp/firebase_cpp_copybara-internal git init --bare /tmp/firebase_cpp_copybara-internal /google/data/ro/teams/copybara/copybara third_party/firebase/cpp/copy.bara.sky piper_to_git_internal --force --ignore-noop git clone /tmp/firebase_cpp_copybara-internal ~/firebase_cpp mkdir ~/firebase_cpp/build cd ~/firebase_cpp/build cmake .. make Error im seeing is: In file included from /usr/include/c++/8/algorithm:62, from ~/firebase_cpp/app/src/reference_counted_future_impl.cc:19: /usr/include/c++/8/bits/stl_algo.h: In instantiation of ‘_IIter std::find_if(_IIter, _IIter, _Predicate) [with _IIter = firebase::intrusive_list<firebase::{anonymous}::CompletionCallbackData>::intrusive_list_iterator<false>; _Predicate = const firebase::CompletionMatcher&]’: ~/firebase_cpp/app/src/reference_counted_future_impl.cc:573:32: required from here /usr/include/c++/8/bits/stl_algo.h:3931:37: error: use of deleted function ‘firebase::CompletionMatcher::CompletionMatcher(const firebase::CompletionMatcher&)’ __gnu_cxx::__ops::__pred_iter(__pred)); *** Original change description *** Automated g4 rollback of changelist 267236680. *** Reason for rollback *** Roll-forward (i.e. rollback of rollback) after fixing the breakage that caused the initial rollback. This CL has three fixes: (1) It incorporates the fixes by varconst@ in CL 267229592, which fixed a problem where some of the references to std::function were not inside "#if defined(FIREBASE_USE_STD_FUNCTION)". (2) It deletes an unnecessary (and wrong) friend declaration that was causing an ambiguity error; ther... *** PiperOrigin-RevId: 268010105
1 parent d3db862 commit 5114ea9

File tree

6 files changed

+139
-1236
lines changed

6 files changed

+139
-1236
lines changed

app/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ set(utility_common_HDRS
220220
src/embedded_file.h
221221
src/function_registry.h
222222
src/future_manager.h
223-
src/intrusive_list.h
224223
src/log.h
225224
src/mutex.h
226225
src/optional.h

app/src/include/firebase/future.h

Lines changed: 27 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ namespace FIREBASE_NAMESPACE {
3737
/// @cond FIREBASE_APP_INTERNAL
3838
namespace detail {
3939
class FutureApiInterface;
40-
class CompletionCallbackHandle;
4140
} // namespace detail
4241
/// @endcond
4342

@@ -85,12 +84,6 @@ class FutureBase {
8584
typedef void (*CompletionCallback)(const FutureBase& result_data,
8685
void* user_data);
8786

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-
9487
/// Construct an untyped future.
9588
FutureBase();
9689

@@ -146,113 +139,34 @@ class FutureBase {
146139
/// pending. Cast is required since GetFutureResult() returns void*.
147140
const void* result_void() const;
148141

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.
158144
///
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.
163147
///
164148
/// When your callback is called, the user_data that you supplied here will be
165149
/// passed back as the second parameter.
166150
///
167151
/// @param[in] callback Function pointer to your callback.
168152
/// @param[in] user_data Optional user data. We will pass this back to your
169153
/// 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;
225155

226156
#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.
228159
///
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.
237162
///
238163
/// @param[in] callback Function or lambda to call.
239-
/// @return A handle that can be passed to RemoveOnCompletion.
240164
///
241165
/// @note This method is not available when using STLPort on Android, as
242166
/// `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;
246168
#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
247169

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-
256170
/// Returns true if the two Futures reference the same result.
257171
bool operator==(const FutureBase& rhs) const {
258172
return api_ == rhs.api_ && handle_ == rhs.handle_;
@@ -368,11 +282,11 @@ class Future : public FutureBase {
368282
return static_cast<const ResultType*>(result_void());
369283
}
370284

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.
373287
///
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.
376290
///
377291
/// When your callback is called, the user_data that you supplied here will be
378292
/// passed back as the second parameter.
@@ -384,20 +298,17 @@ class Future : public FutureBase {
384298
/// @note This is the same callback as FutureBase::OnCompletion(), so you
385299
/// can't expect to set both and have both run; again, only the most recently
386300
/// 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+
}
394305

395306
#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.
398309
///
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.
401312
///
402313
/// @param[in] callback Function or lambda to call.
403314
///
@@ -407,56 +318,12 @@ class Future : public FutureBase {
407318
/// @note This is the same callback as FutureBase::OnCompletion(), so you
408319
/// can't expect to set both and have both run; again, only the most recently
409320
/// 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+
}
458326
#endif // defined(FIREBASE_USE_STD_FUNCTION) || defined(DOXYGEN)
459-
#endif // defined(INTERNAL_EXPERIMENTAL)
460327
};
461328

462329
// NOLINTNEXTLINE - allow namespace overridden

0 commit comments

Comments
 (0)