This project has moved. For the latest updates, please go here.

Advanced Yttrium: MathContext & Simulation Appartments

MathContext is part of the |Microkernel Module and provides a thread and stack-relative context. You may use this class for example to simulate - ''just for now'' - some parts of a system in a new, different simulation apartment. This might be useful e.g. if you want to compute some sub-circuit independent of the rest of the system (and maybe with a different scheduler algorithm).

Context Stack Injection

All contexts share the same root, but the rest of the topology forms a separate stack for each thread. To inject a new context into the current thread's stack, use the following pattern (to ensure the context is disposed and thus removed from the stack):

using(MathContext ctx = MathContext.Create())
{
    // ...
}

Simulation Apartment Injection

The Simulation Mediator of the Simulation Module considers the MathContext when selecting a Scheduler. If you want to inject a separate scheduler, simply inject a new context and then create the new apartment:

using(MathContext ctx = MathContext.Create())
{
    Service<ISimulationMediator>.Instance.CreateSimulationApartement(yourScheduler);
    // ...
}

Last edited Jul 29, 2012 at 1:11 PM by cdrnet, version 1

Comments

No comments yet.