Caching statemachine

156 views
Skip to first unread message

online

unread,
Aug 27, 2012, 11:40:58 AM8/27/12
to dotnet-state-ma...@googlegroups.com
i have a state machine which i want to configure it once in lifetime. (configuration comes from other storage db/xml)..
so i use
machine = new StateMachine<StateType, TriggerType>(() => GetState(), s => SetState(s));    
LoadMachineConfiguration(machine); -> configures the machine

and put it in cache (just a static dictionary)

but the issue is that the delegate of the getstate is not on the current instance (that reads from the cache) but on the instant that the cache was written.

theoreticlay i would have want something like

always creating new state machine with the current instant getstate and set state

and just load its configuration from a cache...

but i dont see how in the current API.

example
new x() { current state= state1} -> get state machine -> gets it from cache , since not exist create new statemachine with the delage (so state now is state1}, configure the machine and puts back in cache
new x() {current state =state2} -> get state machine -> gets it from cache since it exist, but the state machine has current state of state1..

so i need a way to use new state machine every time.. and just cache its configuration..
anyone?


Dan Barua

unread,
Nov 22, 2012, 4:17:53 AM11/22/12
to dotnet-state-ma...@googlegroups.com
This would be useful - it takes about 37ms to configure my state machines, would be nice to shave this off.
Reply all
Reply to author
Forward
0 new messages