Methods Summary |
---|
void | assertReadyToStep()
if (mScheduler == null) {
throw new RuntimeException("Attempting to run schedule with no scheduler in place!");
} else if (getGraph() == null) {
throw new RuntimeException("Calling step on scheduler with no graph in place!");
}
|
public void | beginProcessing()
mScheduler.reset();
getGraph().beginProcessing();
|
public void | close()
// Close filters
if (mLogVerbose) Log.v(TAG, "Closing graph.");
getGraph().closeFilters(mFilterContext);
mScheduler.reset();
|
protected int | determinePostRunState()
boolean isBlocked = false;
for (Filter filter : mScheduler.getGraph().getFilters()) {
if (filter.isOpen()) {
if (filter.getStatus() == Filter.STATUS_SLEEPING) {
// If ANY node is sleeping, we return our state as sleeping
return RESULT_SLEEPING;
} else {
// If a node is still open, it is blocked (by input or output)
return RESULT_BLOCKED;
}
}
}
return RESULT_FINISHED;
|
public synchronized java.lang.Exception | getError()
return null;
|
public FilterGraph | getGraph()
return mScheduler != null ? mScheduler.getGraph() : null;
|
public boolean | isRunning()
return false;
|
boolean | performStep()
if (mLogVerbose) Log.v(TAG, "Performing one step.");
Filter filter = mScheduler.scheduleNextNode();
if (filter != null) {
mTimer.start(filter.getName());
processFilterNode(filter);
mTimer.stop(filter.getName());
return true;
} else {
return false;
}
|
protected void | processFilterNode(Filter filter)
if (mLogVerbose) Log.v(TAG, "Processing filter node");
filter.performProcess(mFilterContext);
if (filter.getStatus() == Filter.STATUS_ERROR) {
throw new RuntimeException("There was an error executing " + filter + "!");
} else if (filter.getStatus() == Filter.STATUS_SLEEPING) {
if (mLogVerbose) Log.v(TAG, "Scheduling filter wakeup");
scheduleFilterWake(filter, filter.getSleepDelay());
}
|
public void | run()
if (mLogVerbose) Log.v(TAG, "Beginning run.");
assertReadyToStep();
// Preparation
beginProcessing();
boolean glActivated = activateGlContext();
// Run
boolean keepRunning = true;
while (keepRunning) {
keepRunning = performStep();
}
// Cleanup
if (glActivated) {
deactivateGlContext();
}
// Call completion callback if set
if (mDoneListener != null) {
if (mLogVerbose) Log.v(TAG, "Calling completion listener.");
mDoneListener.onRunnerDone(determinePostRunState());
}
if (mLogVerbose) Log.v(TAG, "Run complete");
|
protected void | scheduleFilterWake(Filter filter, int delay)
// Close the wake condition
mWakeCondition.close();
// Schedule the wake-up
final Filter filterToSchedule = filter;
final ConditionVariable conditionToWake = mWakeCondition;
mWakeExecutor.schedule(new Runnable() {
@Override
public void run() {
filterToSchedule.unsetStatus(Filter.STATUS_SLEEPING);
conditionToWake.open();
}
}, delay, TimeUnit.MILLISECONDS);
|
public void | setDoneCallback(OnRunnerDoneListener listener)
mDoneListener = listener;
|
public int | step()
assertReadyToStep();
if (!getGraph().isReady() ) {
throw new RuntimeException("Trying to process graph that is not open!");
}
return performStep() ? RESULT_RUNNING : determinePostRunState();
|
public void | stop()
throw new RuntimeException("SyncRunner does not support stopping a graph!");
|
protected void | waitUntilWake()
mWakeCondition.block();
|