Looper: draft possible implementation
seemingly a quite simple "trap door" mechanism is sufficient
This commit is contained in:
parent
ef6ecf3dd0
commit
196696a8d0
3 changed files with 19 additions and 11 deletions
|
|
@ -82,6 +82,7 @@ namespace control {
|
|||
|
||||
bool shutdown_ = false;
|
||||
bool disabled_ = false;
|
||||
uint dirty_ = false;
|
||||
Predicate hasCommandsPending_;
|
||||
|
||||
public:
|
||||
|
|
@ -98,7 +99,7 @@ namespace control {
|
|||
bool isDying() const { return shutdown_; }
|
||||
bool isDisabled() const { return disabled_ or isDying(); }
|
||||
bool isWorking() const { return hasCommandsPending_() and not isDisabled(); }
|
||||
bool runBuild() const { return false; }
|
||||
bool runBuild() const { return (dirty_ and not hasCommandsPending_()) or forceBuild(); }
|
||||
bool isIdle() const { return not (isWorking() or runBuild() or isDisabled()); }
|
||||
|
||||
|
||||
|
|
@ -118,12 +119,14 @@ namespace control {
|
|||
|
||||
/** invoking this function signals
|
||||
* that all consequences of past state changes
|
||||
* have been processed and duly resolved.
|
||||
* have been processed and are duly resolved.
|
||||
*/
|
||||
void
|
||||
markStateProcessed()
|
||||
{
|
||||
UNIMPLEMENTED("state transition logic");
|
||||
if (runBuild())
|
||||
--dirty_;
|
||||
ENSURE (dirty_ <= 2);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -136,8 +139,11 @@ namespace control {
|
|||
bool
|
||||
requireAction()
|
||||
{
|
||||
if (isWorking())
|
||||
dirty_ = 2;
|
||||
|
||||
return isWorking()
|
||||
or runBuild()
|
||||
or forceBuild()
|
||||
or isDying();
|
||||
}
|
||||
|
||||
|
|
@ -162,6 +168,11 @@ namespace control {
|
|||
|
||||
private:
|
||||
static uint establishWakeTimeout();
|
||||
|
||||
bool forceBuild() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
////////////////TODO 12/16 currently just fleshing out the API....
|
||||
|
||||
|
|
@ -177,7 +188,7 @@ namespace control {
|
|||
* period visible to the user as update response delay within the UI.
|
||||
* @todo find a way how to retrieve this value from application config! ////////////////////TICKET #1052 : access application configuration
|
||||
*/
|
||||
uint
|
||||
uint inline
|
||||
Looper::establishWakeTimeout()
|
||||
{
|
||||
return PROC_DISPATCHER_BUILDER_DELAY_ms;
|
||||
|
|
|
|||
|
|
@ -47,12 +47,8 @@
|
|||
#include "proc/control/session-command-service.hpp"
|
||||
#include "proc/mobject/session.hpp"
|
||||
#include "backend/thread-wrapper.hpp"
|
||||
//#include "proc/mobject/mobject-ref.hpp"
|
||||
//#include "proc/mobject/mobject.hpp"
|
||||
//#include "proc/mobject/placement.hpp"
|
||||
|
||||
#include <memory>
|
||||
//using boost::str;
|
||||
|
||||
using backend::ThreadJoinable;
|
||||
using lib::Sync;
|
||||
|
|
@ -71,7 +67,6 @@ namespace control {
|
|||
{
|
||||
bool canDispatch_{false};
|
||||
bool blocked_ {false};
|
||||
bool mustHalt_ {false}; /////////////////TODO this flag shall be relocated into the Looper!
|
||||
|
||||
unique_ptr<SessionCommandService> commandService_;
|
||||
|
||||
|
|
@ -146,7 +141,7 @@ namespace control {
|
|||
{
|
||||
Lock sync(this);
|
||||
commandService_.reset(); // closes Session interface
|
||||
mustHalt_ = true;
|
||||
looper_.triggerShutdown();
|
||||
UNIMPLEMENTED("*must* notify loop thread"); /////////////////TODO really? YES!!!
|
||||
//////////////////////////////////////////TODO notify!!!!
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,6 +168,8 @@ namespace test {
|
|||
CHECK (looper.shallLoop());
|
||||
|
||||
setup.has_commands_in_queue = false;
|
||||
looper.markStateProcessed();
|
||||
looper.markStateProcessed();
|
||||
|
||||
CHECK (not looper.requireAction());
|
||||
CHECK (not looper.isWorking());
|
||||
|
|
|
|||
Loading…
Reference in a new issue