83 #include <boost/lexical_cast.hpp> 95 using boost::lexical_cast;
96 using std::this_thread::sleep_for;
97 using std::chrono::microseconds;
124 uint NUM_INVOC_PER_THRED = 10;
128 maybeOverride (uint& configSetting, Arg cmdline, uint paramNr)
130 if (paramNr < cmdline.size())
131 configSetting = lexical_cast<uint>(cmdline[paramNr]);
137 const Symbol COMMAND_ID{
"test.dispatch.function.command"};
138 const Symbol COMMAND_I1{
"test.dispatch.function.command.instance-1"};
139 const Symbol COMMAND_I2{
"test.dispatch.function.command.instance-2"};
141 TimeVar testCommandState = randTime();
146 testCommandState +=
Offset(dur) + offset*factor;
152 return testCommandState;
158 testCommandState = oldState;
165 #define __DELAY__ sleep_for (20ms); 195 .captureUndo (capture)
196 .undoOperation (undoIt)
203 Command::remove (COMMAND_ID);
204 Command::remove (COMMAND_I1);
205 Command::remove (COMMAND_I2);
211 run (Arg args_for_stresstest)
217 perform_simpleInvocation();
218 perform_messageInvocation();
219 perform_massivelyParallel(args_for_stresstest);
222 lumiera_interfaceregistry_destroy();
239 CHECK (isnil (*problemMessage));
240 thread_has_ended =
true;
244 CHECK (not thread_has_ended);
246 bool thread_has_ended{
false};
258 CHECK (thread_has_ended);
266 string cmdID {COMMAND_I1};
269 CHECK (not
Command(COMMAND_I1).canExec());
271 CHECK (
Command(COMMAND_I1).canExec());
274 Time prevState = testCommandState;
278 CHECK (testCommandState - prevState ==
Time(0, 1));
295 CHECK (commandMsg.idi.getSym() ==
string{COMMAND_I2});
296 CHECK (not Command::canExec(COMMAND_I2));
297 Time prevState = testCommandState;
303 CHECK (testCommandState - prevState ==
Time(FSecs(3,2)));
320 maybeOverride (NUM_INVOC_PER_THRED, args_for_stresstest, 2);
325 class InvocationProducer
330 vector<string> cmdIDs_;
338 cmdIDs_.push_back (
_Fmt(
"%s.thread-%02d.%d") % COMMAND_ID % id_ % j);
339 return cStr(cmdIDs_.back());
347 , thread_{
"producer", [&]{ fabricateCommands(); }}
350 ~InvocationProducer()
352 thread_.
join().maybeThrow();
353 for (
auto&
id : cmdIDs_)
354 Command::remove (
cStr(
id));
363 for (uint j=0; j<NUM_INVOC_PER_THRED; ++j)
373 sendCommandMessage (
GenNode msg)
382 sleep_for (microseconds (1 + random_.
i(MAX_RAND_DELAY_us)));
387 Time prevState = testCommandState;
389 FSecs expectedOffset{0};
391 for (uint j=0; j<NUM_INVOC_PER_THRED; ++j)
392 expectedOffset += FSecs(i*7,2) - FSecs(j,2);
396 deque<InvocationProducer> producerThreads;
398 producerThreads.emplace_back (trigger);
418 CHECK (testCommandState - prevState ==
Time(expectedOffset));
Helper class used solely for defining a Command-Object.
a mutable time value, behaving like a plain number, allowing copy and re-accessing ...
static lib::Depend< SteamDispatcher > instance
storage for Singleton access
Variant of the standard case, requiring to wait and join() on the termination of this thread...
Creating series of type-based contexts.
Global access point to invoke commands and cause edit operations within the Session.
CStr cStr(std::string const &rendered)
convenience shortcut: forced conversion to c-String via string.
int i(uint bound=_iBOUND())
drop-in replacement for rand() % bound
Any copy and copy construction prohibited.
void throwOnError()
Check the lumiera error state, which maybe was set by C-code.
Dispatch and execute mutation operations on the High-level model.
Command storeDef(Symbol newCmdID) const
create a clone definition
Steam-Layer implementation namespace root.
A front-end for using printf-style formatting.
Lumiera's internal time value datatype.
static lib::Depend< SessionCommand > facade
static storage for the facade access front-end
Token or Atom with distinct identity.
Marker types to indicate a literal string and a Symbol.
Simplistic test class runner.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
lib::Result< RES > join()
put the caller into a blocking wait until this thread has terminated
Convenience front-end to simplify and codify basic thread handling.
boost::rational< int64_t > FSecs
rational representation of fractional seconds
A collection of frequently used helper functions to support unit testing.
void lumiera_interfaceregistry_init(void)
Initialise the interface registry.
Global registry for interfaces (extension points).
A one time N-fold mutual synchronisation barrier.
Offset measures a distance in time.
Handle object representing a single Command instance to be used by client code.
void perform_simpleInvocation()
Duration is the internal Lumiera time metric.
Utility to produce member IDs for objects belonging to a "Family", as defined by a distinguishing typ...
lib::time::Time randTime()
create a random but not insane Time value between 1s ...
void perform_massivelyParallel(Arg args_for_stresstest)
void perform_messageInvocation()
Actually defining a command and binding it to execution parameters.
object-like record of data.
Random defaultGen
a global default RandomSequencer for mundane purposes
Major public Interface to the Session subsystem of Lumiera GUI.
generic data element node within a tree
A N-fold synchronisation latch using yield-wait until fulfilment.