File: /home/petsclubcc/magento/vendor/magento/module-cron/Model/ResourceModel/Schedule.php
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Cron\Model\ResourceModel;
/**
* Schedule resource
*
* @author Magento Core Team <core@magentocommerce.com>
*/
class Schedule extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/**
* Initialize resource
*
* @return void
*/
public function _construct()
{
$this->_init('cron_schedule', 'schedule_id');
}
/**
* If job is currently in $currentStatus, set it to $newStatus
* and return true. Otherwise, return false and do not change the job.
* This method is used to implement locking for cron jobs.
*
* @param string $scheduleId
* @param string $newStatus
* @param string $currentStatus
* @return bool
*/
public function trySetJobStatusAtomic($scheduleId, $newStatus, $currentStatus)
{
$connection = $this->getConnection();
$result = $connection->update(
$this->getTable('cron_schedule'),
['status' => $newStatus],
['schedule_id = ?' => $scheduleId, 'status = ?' => $currentStatus]
);
if ($result == 1) {
return true;
}
return false;
}
}