diff options
-rw-r--r-- | include/ui/Fence.h | 23 | ||||
-rw-r--r-- | libs/gui/ConsumerBase.cpp | 8 |
2 files changed, 16 insertions, 15 deletions
diff --git a/include/ui/Fence.h b/include/ui/Fence.h index 58df24c4e0..37811bcd7c 100644 --- a/include/ui/Fence.h +++ b/include/ui/Fence.h @@ -23,8 +23,6 @@ #include <utils/RefBase.h> #include <utils/Timers.h> -#include <experimental/optional> - namespace android { class String8; @@ -105,26 +103,29 @@ public: // error occurs then SIGNAL_TIME_INVALID is returned. nsecs_t getSignalTime() const; -#if __cplusplus > 201103L - // hasSignaled returns whether the fence has signaled yet. Prefer this to + enum class Status { + Invalid, // Fence is invalid + Unsignaled, // Fence is valid but has not yet signaled + Signaled, // Fence is valid and has signaled + }; + + // getStatus() returns whether the fence has signaled yet. Prefer this to // getSignalTime() or wait() if all you care about is whether the fence has - // signaled. Returns an optional bool, which will have a value if there was - // no error. - inline std::experimental::optional<bool> hasSignaled() { + // signaled. + inline Status getStatus() { // The sync_wait call underlying wait() has been measured to be // significantly faster than the sync_fence_info call underlying // getSignalTime(), which might otherwise appear to be the more obvious // way to check whether a fence has signaled. switch (wait(0)) { case NO_ERROR: - return true; + return Status::Signaled; case -ETIME: - return false; + return Status::Unsignaled; default: - return {}; + return Status::Invalid; } } -#endif // Flattenable interface size_t getFlattenedSize() const; diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp index be2b1afd36..c26de6673b 100644 --- a/libs/gui/ConsumerBase.cpp +++ b/libs/gui/ConsumerBase.cpp @@ -318,16 +318,16 @@ status_t ConsumerBase::addReleaseFenceLocked(int slot, return OK; } - auto signaled = mSlots[slot].mFence->hasSignaled(); + auto status = mSlots[slot].mFence->getStatus(); - if (!signaled) { + if (status == Fence::Status::Invalid) { CB_LOGE("fence has invalid state"); return BAD_VALUE; } - if (*signaled) { + if (status == Fence::Status::Signaled) { mSlots[slot].mFence = fence; - } else { + } else { // status == Fence::Status::Unsignaled char fenceName[32] = {}; snprintf(fenceName, 32, "%.28s:%d", mName.string(), slot); sp<Fence> mergedFence = Fence::merge( |