diff options
author | Konstantin Varlamov <var-const@users.noreply.github.com> | 2018-05-08 19:37:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-08 19:37:20 -0400 |
commit | dbcd179788a4cce4e9e3ae545e736148438c5c6f (patch) | |
tree | 1870fa7f448dfeff0ed6d696cd1feb4a60b5e45d /Firestore/core/src/firebase/firestore/util/executor_libdispatch.h | |
parent | 8409f21830f1282a39c4b7888972011f43d2644a (diff) |
Firestore C++: compile ExecutorLibdispatch in Objective-C++ mode (#1237)
dispatch_queue_t is defined differently in libdispatch depending on
whether the library header is being include from Objective-C (or
Objective-C++) code, or else from C or C++ code. Make sure that all
source files in Firestore that include executor_libdispatch.h are
compiled in the same mode (Objective-C++) to avoid linker errors.
Diffstat (limited to 'Firestore/core/src/firebase/firestore/util/executor_libdispatch.h')
-rw-r--r-- | Firestore/core/src/firebase/firestore/util/executor_libdispatch.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Firestore/core/src/firebase/firestore/util/executor_libdispatch.h b/Firestore/core/src/firebase/firestore/util/executor_libdispatch.h index b32dbff..85c34f8 100644 --- a/Firestore/core/src/firebase/firestore/util/executor_libdispatch.h +++ b/Firestore/core/src/firebase/firestore/util/executor_libdispatch.h @@ -17,7 +17,6 @@ #ifndef FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_EXECUTOR_LIBDISPATCH_H_ #define FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_EXECUTOR_LIBDISPATCH_H_ -#include <atomic> #include <chrono> // NOLINT(build/c++11) #include <functional> #include <memory> @@ -30,6 +29,13 @@ #include "Firestore/core/src/firebase/firestore/util/firebase_assert.h" #include "absl/strings/string_view.h" +#if !defined(__OBJC__) +// `dispatch_queue_t` gets defined to different types when compiled in C++ or +// Objective-C mode. Source files including this header should all be compiled +// in the same mode to avoid linker errors. +#error "This header only supports Objective-C++ (see comment for more info)." +#endif // !defined(__OBJC__) + namespace firebase { namespace firestore { namespace util { @@ -78,7 +84,7 @@ class ExecutorLibdispatch : public Executor { absl::string_view GetCurrentQueueLabel() const; absl::string_view GetTargetQueueLabel() const; - std::atomic<dispatch_queue_t> dispatch_queue_; + dispatch_queue_t dispatch_queue_; // Stores non-owned pointers to `TimeSlot`s. // Invariant: if a `TimeSlot` is in `schedule_`, it's a valid pointer. std::vector<TimeSlot*> schedule_; |