summaryrefslogtreecommitdiffstats
path: root/libs/rs/rsLocklessFifo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/rs/rsLocklessFifo.cpp')
-rw-r--r--libs/rs/rsLocklessFifo.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/libs/rs/rsLocklessFifo.cpp b/libs/rs/rsLocklessFifo.cpp
index 4d02269..8879805 100644
--- a/libs/rs/rsLocklessFifo.cpp
+++ b/libs/rs/rsLocklessFifo.cpp
@@ -22,6 +22,9 @@ using namespace android;
using namespace android::renderscript;
LocklessCommandFifo::LocklessCommandFifo() : mBuffer(0), mInitialized(false) {
+ mTimeoutCallback = NULL;
+ mTimeoutCallbackData = NULL;
+ mTimeoutWait = 0;
}
LocklessCommandFifo::~LocklessCommandFifo() {
@@ -125,11 +128,21 @@ void LocklessCommandFifo::commitSync(uint32_t command, uint32_t sizeInBytes) {
void LocklessCommandFifo::flush() {
//dumpState("flush 1");
while (mPut != mGet) {
- mSignalToControl.wait();
+ while (!mSignalToControl.wait(mTimeoutWait)) {
+ if (mTimeoutCallback) {
+ mTimeoutCallback(mTimeoutCallbackData);
+ }
+ }
}
//dumpState("flush 2");
}
+void LocklessCommandFifo::setTimoutCallback(void (*cbk)(void *), void *data, uint64_t timeout) {
+ mTimeoutCallback = cbk;
+ mTimeoutCallbackData = data;
+ mTimeoutWait = timeout;
+}
+
bool LocklessCommandFifo::wait(uint64_t timeout) {
while (isEmpty() && !mInShutdown) {
mSignalToControl.set();