summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Dan Stoza <stoza@google.com> 2017-02-16 14:55:03 -0800
committer Dan Stoza <stoza@google.com> 2017-02-16 14:55:03 -0800
commita34320a81c9787958f1b02e93e828472e54864b5 (patch)
treec7f060f1f052ac6b2431a807432125264cfc3e72
parent52eb3c9f8b436c0e389090436b5aac2b6ff888aa (diff)
libui: Remove STL from Fence
Renames Fence::hasSignaled to Fence::getStatus, and changes its return type from std::experimental::optional (STL is no longer permitted in libui) to an enum class. Also updates its one caller. Test: Builds and sailfish boots Change-Id: I682039b9fd88bf79f1e2a955944c4a564ed6f60b
-rw-r--r--include/ui/Fence.h23
-rw-r--r--libs/gui/ConsumerBase.cpp8
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(