public function synchronized(callable $code)
    {
        return $this->loop->execute(function () use ($code) {
            try {
                // BEGIN
                $this->pdo->beginTransaction();
            } catch (\PDOException $e) {
                throw new LockAcquireException("Could not begin transaction.", 0, $e);
            }
            
            try {
                // Unit of work
                $result = $code();
                $this->pdo->commit();
                $this->loop->end();
                return $result;
            } catch (\Exception $e) {
                $this->rollBack($e);
                
                if (self::hasPDOException($e)) {
                    return; // Replay
                } else {
                    throw $e;
                }
            }
        });
    }