Commit graph

4768 commits

Author SHA1 Message Date
df84de2e81 Library: remove the dispatchSequenced helper
...such can be done way more succinctly with Lambdas now
2017-01-19 23:08:08 +01:00
2045132d3e SessionCommand: multithreaded stress test PASS (closes #1046)
Writing and debugging such tests is always an interesting challenge...

Fortunately this exercise didn't unveil any problem in the newly written
code, only some insidious problems in the test fixture itself. Which
again highlights the necessity, that each *command instance* needs
to be an independent clone from the original *command prototype*,
since argument binding messages and trigger messages can appear
in arbitrary order.
2017-01-14 08:37:46 +01:00
1bebb0ef8d SessionCommand: draft a massive multithreaded stress test 2017-01-14 04:19:58 +01:00
3395d002bd Library: helper to produce threadsafe member-IDs for a family of objects
This is a little bit of functionality needed again and again;
first I thought to use the TypedCounter, but this would be overkill,
since we do not actually need different instances, and we do not need
to select by type when incrementing the counter. In fact, we do not
even need anything beyond just allocating a number.

So I made a new class, which can be used RAII style
2017-01-14 03:07:48 +01:00
0b0575050d SessionCommand: second function test PASS 2017-01-13 09:01:05 +01:00
b52ab62caf SessionCommand: define function test for message based invocation
the intention is to cover more of the full invocation path,
without running all of the application infrastructure. So this
second test cases simulates how messages are handled in CoreService,
where the CommandHandler (visitor) actually invokes the SessionCommand
facade
2017-01-13 08:26:41 +01:00
2d5ef968a8 CommandFramework: fill in a simplified function(integration) test
Start the ProcDispatcher and schedule a command into the session loop thread
2017-01-13 06:13:22 +01:00
edcf503da1 Command-Framework: enable the use of immutable types as state memento 2017-01-13 01:10:05 +01:00
c799c7644c Library: finish adapter to snapshot non-assignable values
this was a spin-off activity from writing the SessionCommand
function(integration) test, where I noted that we can't just
capture "a time value" as command memento
2017-01-12 23:41:20 +01:00
963524254b better provide a dedicated equality operator
basically this is not necessary, since the compiler figures out
to use the conversion to target type when attempting to resolve
an equality comparison. But it helps to avoid ambiguities in cases
where several conversion paths do exist, e.g. when comparing string
with C-string
2017-01-12 20:09:09 +01:00
625787fbba combine instance management with both code paths
for assignable / not assignable types
2017-01-12 08:41:58 +01:00
b6e0497f8b verify instance management
..including the singleton instance in NullValue<Tracker>
2017-01-12 08:02:55 +01:00
f4cd96428c verify a case with indeed non-assignable entities (lumiera Time)
explicitly observed with the debugger that the call path is sane;
the code looks innocuous, but it is quite magic how the compiler
picks precisely the right ctors and inserts conversions apropriately
2017-01-12 07:30:33 +01:00
e60abf66c0 get this wrapper basically to compile
the simple case of an embedded pointer actualy works already
2017-01-12 06:27:31 +01:00
9ba2618844 Library: draft a wrapper to snapshot a non assignable value 2017-01-12 05:21:29 +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
bfebb08015 define test for simple direct dispatching of the command 2017-01-11 05:26:53 +01:00
8a0f26c787 start and stop the Dispatcher for running the function(integration) test
need also to start and stop the interface registry,
since by policy we do not run the application framework itself
for execution of the test suite; thus if some test actually needs
an application service, it must be started/stopped manually
2017-01-11 05:01:47 +01:00
3cc3f69471 SessionCommand: draft the idea of a function(integration) test 2017-01-11 04:19:43 +01:00
104b71e8aa Timehandling: allow default initialisation for Offset values
From a purely logical viewpoint, it looked sensible to require an actual
value for an offset, especially since our time values are immutable.
But this has the unfortunate consequence that we'd be unable to use
an offset value as parameter for any command, since we store the arguments
as tuple and the tuple type has a default constructor. We might be able
to get around that problem, but such looks brittle to me; it is just
plain surprising for anyone not familiar with the internals of the
command system.

For that reason, I've now added a default ctor to the Offset type
2017-01-11 04:09:32 +01:00
2e9bd78791 consider to extend the command handling protocol on UI-Bus (#1058) 2017-01-09 03:24:17 +01:00
38b908d510 CoreService: simple (and obvious) implementation of command handling (#1046)
disregarding all doubts due to the massive indirection
and deferring the question where command-IDs are actually to be allocated....
2017-01-09 02:32:56 +01:00
cfbbb750f8 considerations regarding the integration of commmand invocations (#1046)
not quite sure how to get the design straight.
Also a bit concerned because we'll get this much indirections;
the approach to send invocations via the UI-Bus needs to prove its viability
2017-01-09 01:22:43 +01:00
c2c6262be6 mark where command handling needs to be integrated (#1046) 2017-01-07 03:18:39 +01:00
c0337abcaf Application: from now on start the »session subsystem« (closes #699) 2017-01-07 02:48:51 +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
d74f1447f3 Library: thread self recognition feature defined (#1054) 2017-01-06 23:26:33 +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
567b00aa21 DOC: follow-up of removing boost::scoped_ptr 2017-01-05 01:20:34 +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
34686713d4 Proc-Layer: Builder is not a subsystem (anymore)
We found out that it's best to run it single threaded
within the session loop thread. This does not mean the Builder
itself is necessarily single threaded, but the Builder's top level
will block any other session operation, and this is a good thing.
For this reason it makes more sense to have the Builder integrated
as a component into the session subsystem.
2017-01-03 21:10:27 +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
387a553e98 Lib: fix warning regarding subobject-linkage
And yes, this warning is for real, while the compiler has no way
to decide if there is actual danger lurking. A type with internal
linkage (e.g. defined in an anonymous namespace) will be treated
by the linker as a separate entity on each encounter (i.e. in
each distinct compilation unit). When multiple translation units
start collaborating on such a type, they *might* be referring
to different memory locations, while semantically the intention
is to refer to the same location.

And since we're dealing with a library facility here, *we* have
likewise now power to ensure proper usage, so we better be cautious.
2016-12-25 20:09:24 +01:00
3501732839 CommandQueue: simple interface 2016-12-25 19:30:59 +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
386c15f039 obviously a better name
...since it became customary to have make_tuple, make_shared, make_unique
2016-12-23 04:24:22 +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