4 * Deferrable Update for closure/callback updates via IDatabase::doAtomicSection()
7 class AtomicSectionUpdate
implements DeferrableUpdate
{
12 /** @var Closure|callable */
16 * @param IDatabase $dbw
17 * @param string $fname Caller name (usually __METHOD__)
18 * @param callable $callback
19 * @throws InvalidArgumentException
20 * @see IDatabase::doAtomicSection()
22 public function __construct( IDatabase
$dbw, $fname, $callback ) {
24 $this->fname
= $fname;
25 if ( !is_callable( $callback ) ) {
26 throw new InvalidArgumentException( 'Not a valid callback/closure!' );
28 $this->callback
= $callback;
31 public function doUpdate() {
32 $this->dbw
->doAtomicSection( $this->fname
, $this->callback
);