re-entrant state machines