src/ServiceRuntime/RoleEnvironment.php
public static function trackChanges()
    {
        self::_initialize(true);

        while (self::$_tracking) {
            $newGoalState = self::$_runtimeClient->getCurrentGoalState();

            switch ($newGoalState->getExpectedState()) {
            case CurrentStatus::STARTED:
                $newIncarnation = $newGoalState->getIncarnation();
                $currentIncarnation = self::$_currentGoalState->getIncarnation();

                if ($newIncarnation > $currentIncarnation) {
                    self::_processGoalStateChange($newGoalState);
                }

                break;
            case CurrentStatus::STOPPED:
                self::_raiseStoppingEvent();

                $stoppedState = new AcquireCurrentState(
                    self::$_clientId,
                    $newGoalState->getIncarnation(),
                    CurrentStatus::STOPPED,
                    self::$_maxDateTime
                );

                self::$_runtimeClient->setCurrentState($stoppedState);
                break;
            }

            if (is_int(self::$_tracking)) {
                --self::$_tracking;
            }
        }
    }
public static function trackChanges()
    {
        self::_initialize(true);

        while (self::$_tracking) {
            $newGoalState = self::$_runtimeClient->getCurrentGoalState();

            switch ($newGoalState->getExpectedState()) {
            case CurrentStatus::STARTED:
                $newIncarnation = $newGoalState->getIncarnation();
                $currentIncarnation = self::$_currentGoalState->getIncarnation();

                if ($newIncarnation > $currentIncarnation) {
                    self::_processGoalStateChange($newGoalState);
                }

                break;
            case CurrentStatus::STOPPED:
                self::_raiseStoppingEvent();

                $stoppedState = new AcquireCurrentState(
                    self::$_clientId,
                    $newGoalState->getIncarnation(),
                    CurrentStatus::STOPPED,
                    self::$_maxDateTime
                );

                self::$_runtimeClient->setCurrentState($stoppedState);
                break;
            }

            if (is_int(self::$_tracking)) {
                --self::$_tracking;
            }
        }
    }
public static function trackChanges ( ) { self :: _initialize ( true ) ; while ( self :: $ _tracking ) { $ newGoalState = self :: $ _runtimeClient -> getCurrentGoalState ( ) ; switch ( $ newGoalState -> getExpectedState ( ) ) { case CurrentStatus :: STARTED : $ newIncarnation = $ newGoalState -> getIncarnation ( ) ; $ currentIncarnation = self :: $ _currentGoalState -> getIncarnation ( ) ; if ( $ newIncarnation > $ currentIncarnation ) { self :: _processGoalStateChange ( $ newGoalState ) ; } break ; case CurrentStatus :: STOPPED : self :: _raiseStoppingEvent ( ) ; $ stoppedState = new AcquireCurrentState ( self :: $ _clientId , $ newGoalState -> getIncarnation ( ) , CurrentStatus :: STOPPED , self :: $ _maxDateTime ) ; self :: $ _runtimeClient -> setCurrentState ( $ stoppedState ) ; break ; } if ( is_int ( self :: $ _tracking ) ) { -- self :: $ _tracking ; } } }
Tracks role environment changes raising events as necessary.

This method is blocking and can/should be called in a separate fork.

@static
Tracks role environment changes raising events as necessary .