Commit graph

235 commits

Author SHA1 Message Date
edcf503da1 Command-Framework: enable the use of immutable types as state memento 2017-01-13 01:10:05 +01:00
3a5790e422 add preliminary magic to dispatch test commands without much ado
command processing against the session is not yet implemented,
so to allow for unit testing, we magically recognise all commands
starting with "test." and invoke them directly within the Dispatcher.

With this addition, the basic functionality of the dispatcher works now
2017-01-11 06:09:34 +01:00
2535e1b554 DispatcherLoop: no timeout turnaround necessary in idle state
...since the session loop will be notified on any change via the
interface, adding a command will activate the loop, and the builder
timeout is handled separately via the dirty state. So there is no
need to spin around the loop in idle state.

As a aside, timeout waiting on a condition variable can be intentional
and should thus not be logged as an error automatically. It is up to the
calling context to decide if a timeout constitutes an exceptional situation.

It is always a trade-off performance vs. readability.
Sometimes a single-threaded implementation of self-contained logic
is preferable to a slightly more performant yet obscure implementation
based on our threadpool and scheduler.
2017-01-07 02:46:34 +01:00
dd041ff80c Library: thread self recognition implemented and tested (closes #1054) 2017-01-07 01:01:39 +01:00
458fda4058 DispatcherLoop implementation complete (closes #1049)
Did a full review of state and locking logic, seems airtight now.
- command processing itself is unimplemented, we log a TODO message for now
- likewise, builder is not implemented
- need to add the deadlock safeguard #1054
2017-01-05 23:36:42 +01:00
b0b662f200 DispatcherLoop: fix race on initialisation 2017-01-05 22:35:33 +01:00
3915e3230e DispatcherLoop: add wake-up notification on state change 2017-01-05 21:40:37 +01:00
f26ef5230c CommandQueue: finish integration into ProcDispatcher
...leaving out the *actual operations* of
- command dispatch
- builder run
2017-01-05 20:43:53 +01:00
1b970cd943 Session-Subsytem(#318): finish review of locking and lifecycle sanity
This subsystem as such can be considered as implemented now,
while several details still wait to be filled in.
2017-01-05 03:38:46 +01:00
3809240312 ProcDispatcher(#318): forgo joining the loop thread to avoid deadlock
Due to object scoping we can conclude reliably that the only one
ever to delete the DispacherLoop object will be the the loop thread
from within this object itself, when invoking the termination callback.

Btw, the lock on the inner object was insufficient and will be
replaced by taking the outer lock
2017-01-05 02:00:35 +01:00
cd8844b409 clean-up: kill Boost scoped_ptr
std::unique_ptr is a drop-in replacement
2017-01-05 00:56:46 +01:00
77303ad007 Session-Subsystem(#318): investigation of locking sanity (ongoing...)
Found an inconsistency and a deadlock!
See proc-dispatcher.cpp, the lambda embedded into the start() operation!
2017-01-04 01:44:35 +01:00
282829956b ProcDispatcher: integrate queue and finish preliminary implementation draft
TODO: the wakeup / notification on changes still needs to be done consistently
2016-12-25 22:26:16 +01:00
3010c87008 CommandQueue: basic queue behaviour implemented and tested 2016-12-25 21:52:52 +01:00
b58427e49f Command-Framework: mark anonymous commands
It turns out we *do* support the use of anonymous commands
(while it is not clear yet if we really need this feature).

Basically, client code may either create and register a new
instance from another command used as prototype, by invoking
Command::storeDef(ID). Or, alternatively it may just invoke
newInstance() on the command, which creates a new handle
and a valid new implementation (managed by the handle as
smart-ptr), but never stores this implementation into the
CommandRegistry. In that case, client code may use such a
command just fine, as long as it cares to hold onto that
handle; but it is not possible to retrieve this command
instance later by symbolic ID.

In the light of this (possible) usage pattern, it doesn't
make sense to throw when accessing a command-ID. Rather, we
now return a placeholder-Symbol ("_anonymous_")
2016-12-25 21:46:58 +01:00
b5590fb22c CommandQueue: prepare for an unit test 2016-12-25 18:49:57 +01:00
b6d5cd1c76 SessionCommandService implemented by delegating to the ProcDispatcher 2016-12-23 23:42:27 +01:00
b3f0605b9b SessionCommand-facade: consider how to expose command invocation
after reading some related code, I am leaning towards a design
to mirror the way command messages are sent over the UI-Bus.

Unfortunately this pretty much abandons the possibility to
invoke these operations from a client written in C or any
other hand made language binding. Which pretty much confirms
my initial reservation towards such an excessively open
and generic interface system.
2016-12-23 07:26:00 +01:00
1a4b6545a0 maximum munch
...feels like X-mas
2016-12-23 04:23:03 +01:00
39060297ee ProcDispatcher: solve the sync waiting for a "checkpoint"
...based on the logic of the whole loop
2016-12-22 21:36:03 +01:00
8bbc0fb97f more clean-up and comments 2016-12-22 19:35:42 +01:00
ad6a2ef090 ProcDispatcher: fix possible race at startup 2016-12-22 18:42:12 +01:00
0d436deb9e clean-up and comments for the implementation finished thus far 2016-12-22 04:04:41 +01:00
99b9af0a74 Looper: loop control logic unit test PASS 2016-12-22 03:28:41 +01:00
96def6b1ba Looper: elaborate implementation
looks doable indeed...
2016-12-22 03:12:14 +01:00
196696a8d0 Looper: draft possible implementation
seemingly a quite simple "trap door" mechanism is sufficient
2016-12-21 03:56:56 +01:00
ef6ecf3dd0 Looper: rework the spec for the builder triggereing behaviour
...still don't know how to implement it, but now it is at least
specified more correct, with respect to the implementation of the loop
2016-12-21 03:15:36 +01:00
6073df3554 Looper: other (better?) idea how to handle "builder dirty" automatically
...this means to turn Looper into a state machine.
Yet it seems more feasible, since the DispatcherLoop has a nice
checkpoint after each iteration through the while loop, and we'd
keep that whole builder-dirty business completely confined within
the Looper (with a little help of the DispatcherLoop)

Let's see if the state transition logic can actually be implemented
based just on such a checkpoint....?
2016-12-20 03:53:48 +01:00
bae3d4b96f mark a solution how to create a safeguard against deadlock on session shutdown
....if by some weird coincidence, a command dispatched into the session
happens to trigger session shutdown or re-loading, this will cause a deadlock,
since decommissioning of session data structures must wait for the
ProcDispatcher to disable command processing -- and this will obviously
never happen when in a callstack below some command execution!
2016-12-20 02:35:45 +01:00
b873f7025b ProcDispatcher: mark some next tasks to care for 2016-12-16 23:26:56 +01:00
53ed0e9aa3 ProcDispatcher: consider and document the fine points of operational semantics
there are some pitfalls related to timing and state,
especially since some state changes are triggered, but not immediately reached
2016-12-16 23:11:19 +01:00
8ee08905b3 Looper: extend test coverage 2016-12-16 20:38:00 +01:00
30254da95f Looper: implement core operation control logic 2016-12-16 19:21:06 +01:00
af92ed505b Looper: implementation 2016-12-16 18:34:04 +01:00
7b860947b1 ProcDispatcher: skeleton of the processing loop
including a draft of the Looper control component and the
invocation of the object monitor for waiting on condition var
2016-12-15 22:15:20 +01:00
00077d0431 ProcDispatcher: decide on requirements and implementation structure (#1049) 2016-12-15 20:48:35 +01:00
7e65dda771 draft request to halt the dispatcher loop 2016-12-15 06:21:59 +01:00
86f446c197 better control of the shutdown sequence
holding the SessionCommandService in a unique_ptr allows us to
close the Interface reliably *before* the Loop is halted.
2016-12-15 05:54:48 +01:00
a3c22b8aff SessionCommandService to be operated by the DispatcherLoop 2016-12-15 05:38:12 +01:00
4d45dfd4be introduce CommandDispatch interface
this allows to let the DispatcherLoop actually serve
as implementation facility for the SessionCommandService
2016-12-15 05:21:03 +01:00
1ec883787a DOC: decision about where to home the SessionCommandService
After some consideration, it became clear that this service implementation
is closely tied to the DispatcherLoop -- which will consequently be
responsible to run and expose this service implementation
2016-12-15 05:07:40 +01:00
479f4170c2 implement activated state
need to keep state variables on both levels,
since the session manager (lifecycle) "opens" the session
for external access by starting the dispatcher; it may well happen
thus that the session starts up, while the *session subsystem*
is not(yet) started
2016-12-14 04:57:08 +01:00
a853851447 add complete locking to the ProcDispatcher
on both levels
- the front-end needs locking to ensure consistent state (memory barrier)
- the back-end nees locking to coordinate command processing
2016-12-14 04:18:58 +01:00
4c30c349aa change the way command dispatching is controlled by the session
"command dispatching" == the public session interface
so we'll better implement this important causal link directly,
instead of some obscure trickery with lifecycle events.
2016-12-14 03:59:13 +01:00
8da9858056 draft skeleton of the dispatcher loop thread 2016-12-13 04:45:00 +01:00
1a8408afb5 rework ProcDispatcher to run dispatcher thread as PImpl
note the idea is to have a joinable thread, where deleting
the enclosing object blocks until the thread is finished
2016-12-13 04:34:28 +01:00
014a828c63 next task: implement minimal "Session subsystem" (#318)
mark TODOs in code to make that happen.
Actually, it is not hard to do so, it just requires to combine
all the existing building blocks. When this is done, we can define
the "Session" subsystem as prerequisite for "GUI" in main.cpp

Unless I've made some (copy-n-paste) mistake with defining the facades,
this should be sufficient to pull up "the Session" and automatically
let the Gui-Plugin connect against the SessionCommandService
2016-12-12 03:45:21 +01:00
c144d15e65 add two placeholder functions for now
...soon to be replaced by the actual stuff, but right now
I am only concerned with getting all the boilerplate straight
2016-12-12 03:16:29 +01:00
4975712b5e copy-n-paste-programming to define SessionCommand interface / service
...the sheer amount of mechanical replacements scattered all over these
files might be a vivid indication, that the design of the interface system
is subobptimal ;-)
2016-12-12 03:09:08 +01:00
64e303999e WIP: start definition of SessionCommand interface 2016-12-12 02:55:32 +01:00