92 #include <boost/lexical_cast.hpp> 104 using boost::lexical_cast;
105 using std::this_thread::sleep_for;
106 using std::chrono::microseconds;
133 uint NUM_INVOC_PER_THRED = 10;
137 maybeOverride (uint& configSetting, Arg cmdline, uint paramNr)
139 if (paramNr < cmdline.size())
140 configSetting = lexical_cast<uint>(cmdline[paramNr]);
146 const Symbol COMMAND_ID{
"test.dispatch.function.command"};
147 const Symbol COMMAND_I1{
"test.dispatch.function.command.instance-1"};
148 const Symbol COMMAND_I2{
"test.dispatch.function.command.instance-2"};
150 TimeVar testCommandState = randTime();
155 testCommandState +=
Offset(dur) + offset*factor;
161 return testCommandState;
167 testCommandState = oldState;
174 #define __DELAY__ sleep_for (20ms); 204 .captureUndo (capture)
205 .undoOperation (undoIt)
212 Command::remove (COMMAND_ID);
213 Command::remove (COMMAND_I1);
214 Command::remove (COMMAND_I2);
220 run (Arg args_for_stresstest)
226 perform_simpleInvocation();
227 perform_messageInvocation();
228 perform_massivelyParallel(args_for_stresstest);
231 lumiera_interfaceregistry_destroy();
248 CHECK (isnil (*problemMessage));
249 thread_has_ended =
true;
253 CHECK (not thread_has_ended);
255 bool thread_has_ended{
false};
267 CHECK (thread_has_ended);
275 string cmdID {COMMAND_I1};
278 CHECK (not
Command(COMMAND_I1).canExec());
280 CHECK (
Command(COMMAND_I1).canExec());
283 Time prevState = testCommandState;
287 CHECK (testCommandState - prevState ==
Time(0, 1));
304 CHECK (commandMsg.idi.getSym() ==
string{COMMAND_I2});
305 CHECK (not Command::canExec(COMMAND_I2));
306 Time prevState = testCommandState;
312 CHECK (testCommandState - prevState ==
Time(FSecs(3,2)));
328 maybeOverride(NUM_INVOC_PER_THRED, args_for_stresstest, 2);
333 class InvocationProducer
338 vector<string> cmdIDs_;
345 cmdIDs_.push_back (
_Fmt(
"%s.thread-%02d.%d") % COMMAND_ID % id_ % j);
346 return cStr(cmdIDs_.back());
353 , thread_{
"producer", [&]{ fabricateCommands(); }}
356 ~InvocationProducer()
358 thread_.
join().maybeThrow();
359 for (
auto&
id : cmdIDs_)
360 Command::remove (
cStr(
id));
369 for (uint j=0; j<NUM_INVOC_PER_THRED; ++j)
379 sendCommandMessage(
GenNode msg)
388 sleep_for (microseconds (1 + rand() % MAX_RAND_DELAY_us));
393 Time prevState = testCommandState;
395 FSecs expectedOffset{0};
397 for (uint j=0; j<NUM_INVOC_PER_THRED; ++j)
398 expectedOffset += FSecs(i*7,2) - FSecs(j,2);
402 deque<InvocationProducer> producerThreads;
404 producerThreads.emplace_back (trigger);
424 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.
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.
Simple 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.
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.