public function schedule(TimerInterface $timer)
    {

        // force handling the timer tasks now
        $this->synchronized(function (TimerInterface $t) {

            // store the timer-ID and the PK of the timer service => necessary to load the timer later
            $this->scheduledTimers[$timerId = $t->getId()] = $t->getTimerService()->getPrimaryKey();

            // create a wrapper instance for the timer task that we want to schedule
            $timerTaskWrapper = new \stdClass();
            $timerTaskWrapper->executeAt = microtime(true) + ($t->getTimeRemaining() / 1000000);
            $timerTaskWrapper->taskId = uniqid();
            $timerTaskWrapper->timerId = $timerId;

            // schedule the timer tasks as wrapper
            $this->tasksToExecute[$timerTaskWrapper->taskId] = $timerTaskWrapper;

        }, $timer);
    }
public function schedule(TimerInterface $timer)
    {

        // force handling the timer tasks now
        $this->synchronized(function (TimerInterface $t) {

            // store the timer-ID and the PK of the timer service => necessary to load the timer later
            $this->scheduledTimers[$timerId = $t->getId()] = $t->getTimerService()->getPrimaryKey();

            // create a wrapper instance for the timer task that we want to schedule
            $timerTaskWrapper = new \stdClass();
            $timerTaskWrapper->executeAt = microtime(true) + ($t->getTimeRemaining() / 1000000);
            $timerTaskWrapper->taskId = uniqid();
            $timerTaskWrapper->timerId = $timerId;

            // schedule the timer tasks as wrapper
            $this->tasksToExecute[$timerTaskWrapper->taskId] = $timerTaskWrapper;

        }, $timer);
    }
public function schedule ( TimerInterface $ timer ) { // force handling the timer tasks now $ this -> synchronized ( function ( TimerInterface $ t ) { // store the timer-ID and the PK of the timer service => necessary to load the timer later $ this -> scheduledTimers [ $ timerId = $ t -> getId ( ) ] = $ t -> getTimerService ( ) -> getPrimaryKey ( ) ; // create a wrapper instance for the timer task that we want to schedule $ timerTaskWrapper = new \ stdClass ( ) ; $ timerTaskWrapper -> executeAt = microtime ( true ) + ( $ t -> getTimeRemaining ( ) / 1000000 ) ; $ timerTaskWrapper -> taskId = uniqid ( ) ; $ timerTaskWrapper -> timerId = $ timerId ; // schedule the timer tasks as wrapper $ this -> tasksToExecute [ $ timerTaskWrapper -> taskId ] = $ timerTaskWrapper ; } , $ timer ) ; }
Adds the passed timer task to the schedule.

@param \AppserverIo\Psr\EnterpriseBeans\TimerInterface $timer The timer we want to schedule

@return void
Adds the passed timer task to the schedule .