wiki.techinc.nl/includes/deferred/TransactionRoundDefiningUpdate.php
Timo Tijhof 6b2f8639b6 deferred: Introduce TransactionRoundDefiningUpdate
This allows scheduling of updates that need to start their own
transaction round. Specifically for cases where the ability to
commit early is not enough (which is already possible via LBFactory
getEmptyTransactionTicket and commitAndWaitForReplication).

Change-Id: I0910587b61c8ddf825f91e92c2f93582cc7ebd80
2017-10-13 21:24:11 +00:00

31 lines
678 B
PHP

<?php
/**
* Deferrable update for closure/callback updates that need LBFactory and Database
* to be outside any active transaction round.
*
* @since 1.31
*/
class TransactionRoundDefiningUpdate implements DeferrableUpdate, DeferrableCallback {
/** @var callable|null */
private $callback;
/** @var string */
private $fname;
/**
* @param callable $callback
* @param string $fname Calling method
*/
public function __construct( callable $callback, $fname = 'unknown' ) {
$this->callback = $callback;
$this->fname = $fname;
}
public function doUpdate() {
call_user_func( $this->callback );
}
public function getOrigin() {
return $this->fname;
}
}