clarify some aspects of Session lifecycle
- consider especially where the reset of internal indices happens - actively purge the Assets, the ConfigRules and Defaults
This commit is contained in:
parent
aadc7ec7f8
commit
933e486cf9
6 changed files with 49 additions and 12 deletions
|
|
@ -199,6 +199,10 @@ namespace lumiera {
|
|||
virtual ~ConfigRules() {}
|
||||
|
||||
public:
|
||||
/** roll back to a pristine yet operational state.
|
||||
* Discards all information collected through use */
|
||||
virtual void reset() =0;
|
||||
|
||||
// TODO: find out what operations we need to support here for the »real solution« (using Prolog)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -51,12 +51,12 @@
|
|||
|
||||
#include "proc/asset/struct-scheme.hpp"
|
||||
|
||||
#include "lib/format-string.hpp"
|
||||
#include "lib/query-util.hpp"
|
||||
#include "lib/symbol.hpp"
|
||||
#include "lib/error.hpp"
|
||||
#include "lib/util.hpp"
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
|
|
@ -64,9 +64,8 @@
|
|||
namespace proc {
|
||||
namespace asset {
|
||||
|
||||
using boost::format;
|
||||
|
||||
using lib::Symbol;
|
||||
using util::_Fmt;
|
||||
using util::uNum;
|
||||
using util::isnil;
|
||||
using util::contains;
|
||||
|
|
@ -119,8 +118,9 @@ namespace asset {
|
|||
// no name-ID contained in the query...
|
||||
// so we'll create a new one
|
||||
static int i=0;
|
||||
static format namePattern ("%s.%d");
|
||||
nameID = str(namePattern % StructTraits<STRU>::namePrefix() % (++i) );
|
||||
nameID = _Fmt("%s.%d")
|
||||
% StructTraits<STRU>::namePrefix()
|
||||
% (++i);
|
||||
}
|
||||
ENSURE (!isnil (nameID));
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ namespace asset {
|
|||
template<class STRU>
|
||||
STRU* fabricate (Query<STRU> const& caps)
|
||||
{
|
||||
throw error::Config ( str(format("The following Query could not be resolved: %s.") % caps.asKey())
|
||||
throw error::Config ("The following Query could not be resolved: " + caps.asKey()
|
||||
, LUMIERA_ERROR_CAPABILITY_QUERY );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
** Implementation facility providing an operation skeleton of session lifecycle.
|
||||
** This header is intended to be included into the session manager implementation;
|
||||
** it should not be used by client code otherwise. The purpose of the LifecycleAdvisor
|
||||
** is to to get a consolidated view on the whole lifecycle. Reading this source file
|
||||
** is to get a consolidated view on the whole lifecycle. Reading this source file
|
||||
** should convey a complete picture about what is going on with respect to the
|
||||
** session lifecycle. Besides that, no actual implementation code is to be found
|
||||
** here; any implementation is delegated to the relevant session facilities.
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
** The idea of a LifecycleAdvisor is inspired by GUI frameworks, especially
|
||||
** Spring RichClient. Typically, such frameworks provide a means for flexible
|
||||
** configuration of the application lifecycle. Configurability isn't the primary
|
||||
** goal here, as there is only one Lumiera application and the session lifecycle
|
||||
** goal here, as there is only one Lumiera application and the session lifecycle
|
||||
** can be considered fixed, with the exception of some extension points, which are
|
||||
** implemented as "lifecycle events".
|
||||
**
|
||||
|
|
@ -89,7 +89,7 @@ namespace session {
|
|||
void
|
||||
pullUp()
|
||||
{
|
||||
createSessionFacilities();
|
||||
createSessionFacilities(); // includes switch of the "current" Session
|
||||
emitEvent (ON_SESSION_START);
|
||||
injectSessionContent();
|
||||
emitEvent (ON_SESSION_INIT);
|
||||
|
|
@ -106,7 +106,8 @@ namespace session {
|
|||
* cleanup and consolidation routines, the command framework is
|
||||
* disconnected from the log, discarding any pending commands.
|
||||
* This brings the session subsystem back into \em de-configured
|
||||
* state, all asset and content objects pending eviction.
|
||||
* state, all asset and content objects pending eviction,
|
||||
* and the internal knowledge-base rolled back to zero.
|
||||
*/
|
||||
void
|
||||
shutDown()
|
||||
|
|
@ -132,7 +133,11 @@ namespace session {
|
|||
|
||||
|
||||
/**
|
||||
*
|
||||
* Build and wire all the sub components together forming the session implementation.
|
||||
* All these components are created to be operational in principle, but not initialised
|
||||
* or outfitted with actual boilerplate state. After leaving this function, all of the
|
||||
* technical / implementation level invariants are fulfilled. As a final step,
|
||||
* the "current" session pointer is switched.
|
||||
*/
|
||||
virtual void createSessionFacilities() =0;
|
||||
|
||||
|
|
@ -174,7 +179,16 @@ namespace session {
|
|||
|
||||
|
||||
/**
|
||||
*
|
||||
* This final stage of the session lifecycle terminates the operational state of
|
||||
* all parts of the current session. When entering this phase, it can be assumed
|
||||
* that no entity from outside the session will access any of these parts anymore.
|
||||
* Now, all the internal indices and knowledge registries are advised to purge,
|
||||
* thereby rendering any session content officially non-existent.
|
||||
* @note even after leaving this phase, all session components remain valid
|
||||
* and basically operational. Already disconnected render processes
|
||||
* might still access implementation facilities or session content.
|
||||
* The actual unwinding and destruction is controlled by memory
|
||||
* management and thus by reference count.
|
||||
*/
|
||||
virtual void deconfigure() =0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -108,6 +108,19 @@ namespace session {
|
|||
}
|
||||
|
||||
|
||||
/** clear the contents of the mock solution table.
|
||||
* Used by Session lifecycle to restore pristine state
|
||||
*/
|
||||
void
|
||||
MockTable::reset()
|
||||
{
|
||||
answer_.clear();
|
||||
isInit_ = false;
|
||||
INFO (config, "discarded all config query mock answers.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* under some circumstances we need to emulate the behaviour *
|
||||
|
|
@ -183,6 +196,7 @@ namespace session {
|
|||
if (!newTimeline)
|
||||
newTimeline = Struct::retrieve.made4fake (normalisedQuery); // no suitable Timeline found: create and attach new one
|
||||
answer_.insert (entry<aTL> (normalisedQuery, newTimeline)); // "learn" the found/created Timeline as new solution
|
||||
answer_.insert (entry<aTL> (query, newTimeline));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -218,6 +232,7 @@ namespace session {
|
|||
if (!newSequence)
|
||||
newSequence = Struct::retrieve.made4fake (normalisedQuery); // no suitable found: create and attach new Sequence
|
||||
answer_.insert (entry<aSeq> (normalisedQuery, newSequence)); // "learn" the found/created new solution
|
||||
answer_.insert (entry<aSeq> (query, newSequence));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ namespace session {
|
|||
|
||||
protected:
|
||||
MockTable ();
|
||||
virtual void reset();
|
||||
any const& fetch_from_table_for (QueryKey const& query);
|
||||
|
||||
// special cases....
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
#include "proc/mobject/session.hpp"
|
||||
#include "proc/mobject/session/sess-manager-impl.hpp"
|
||||
#include "proc/mobject/session/lifecycle-advisor.hpp"
|
||||
#include "proc/config-resolver.hpp"
|
||||
#include "proc/asset/timeline.hpp"
|
||||
#include "common/query/defs-manager.hpp"
|
||||
#include "common/query.hpp"
|
||||
|
|
@ -175,6 +176,8 @@ namespace session {
|
|||
void
|
||||
deconfigure()
|
||||
{
|
||||
session_->defaults.clear();
|
||||
ConfigResolver::instance().reset(); // forget any configuration rules
|
||||
AssetManager::instance().clear();
|
||||
/////////////////////////////////////////////////////////////////// TICKET #154
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue