Work in progress
This work extends AIStateMachine to run multiplex() in the thread that calls run(), cont() or set_state(). Note that all three eventually call locked_cont(), so thats where multiplex() is called from. Calling multiplex() means "running the state machine", as in "calling multiplex_impl". Currently only LLURLRequest uses this feature, and then only for the HTTPGetResponder, and well only for the initializing, start up and normal finish states. A current/remaining problem is that we run into a situation where the curl thread runs a statemachine to it's finish and kills it, while the main thread is also 'running' it and tries to call multiplex while the statemachine isn't running anymore.
This commit is contained in:
@@ -33,7 +33,8 @@
|
||||
|
||||
enum timer_state_type {
|
||||
AITimer_start = AIStateMachine::max_state,
|
||||
AITimer_expired
|
||||
AITimer_expired,
|
||||
AITimer_abort
|
||||
};
|
||||
|
||||
char const* AITimer::state_str_impl(state_type run_state) const
|
||||
@@ -42,6 +43,7 @@ char const* AITimer::state_str_impl(state_type run_state) const
|
||||
{
|
||||
AI_CASE_RETURN(AITimer_start);
|
||||
AI_CASE_RETURN(AITimer_expired);
|
||||
AI_CASE_RETURN(AITimer_abort);
|
||||
}
|
||||
return "UNKNOWN STATE";
|
||||
}
|
||||
@@ -52,6 +54,12 @@ void AITimer::initialize_impl(void)
|
||||
set_state(AITimer_start);
|
||||
}
|
||||
|
||||
void AITimer::request_abort(void)
|
||||
{
|
||||
mFrameTimer.cancel();
|
||||
set_state(AITimer_abort);
|
||||
}
|
||||
|
||||
void AITimer::expired(void)
|
||||
{
|
||||
set_state(AITimer_expired);
|
||||
@@ -64,7 +72,7 @@ void AITimer::multiplex_impl(void)
|
||||
case AITimer_start:
|
||||
{
|
||||
mFrameTimer.create(mInterval, boost::bind(&AITimer::expired, this));
|
||||
idle();
|
||||
idle(AITimer_start);
|
||||
break;
|
||||
}
|
||||
case AITimer_expired:
|
||||
@@ -72,6 +80,11 @@ void AITimer::multiplex_impl(void)
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
case AITimer_abort:
|
||||
{
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user