WorkerFactory.php
private function transactKillSwitch(callable $operation)
    {
        $ksPath = $this->bootstrapProfile->getKillSwitchPath();
        if ($ksPath === null) {
            throw new Exception\LogicException('No kill switch has been configured');
        }
        $lock = Lock::acquire();
        $kswitch = new KillSwitch($ksPath);
        $retval = call_user_func($operation, $kswitch);
        $kswitch->save();
        $lock->release();

        return ($retval !== null) ? $retval : $this;
    }
private function transactKillSwitch(callable $operation)
    {
        $ksPath = $this->bootstrapProfile->getKillSwitchPath();
        if ($ksPath === null) {
            throw new Exception\LogicException('No kill switch has been configured');
        }
        $lock = Lock::acquire();
        $kswitch = new KillSwitch($ksPath);
        $retval = call_user_func($operation, $kswitch);
        $kswitch->save();
        $lock->release();

        return ($retval !== null) ? $retval : $this;
    }
@param callable $operation

@throws Exception\LogicException

@return mixed|$this