Lock the table.

return boolean True on success, false otherwise.
181161
public function lock()
    {
        $result = null;

        $context = $this->getContext();
        $context->table = $this->getBase();

        if ($this->invokeCommand('before.lock', $context) !== false)
        {
            if ($this->isConnected()) {
                $context->result = $this->getDriver()->lock($this->getBase());
            }

            $this->invokeCommand('after.lock', $context);
        }

        return $context->result;
    }
724292
public function isLockedOut()
    {
        /** @var DBDatetime $lockedOutUntilObj */
        $lockedOutUntilObj = $this->dbObject('LockedOutUntil');
        if ($lockedOutUntilObj->InFuture()) {
            return true;
        }

        $maxAttempts = $this->config()->get('lock_out_after_incorrect_logins');
        if ($maxAttempts <= 0) {
            return false;
        }

        $idField = static::config()->get('unique_identifier_field');
        $attempts = LoginAttempt::getByEmail($this->{$idField})
            ->sort('Created', 'DESC')
            ->limit($maxAttempts);

        if ($attempts->count() < $maxAttempts) {
            return false;
        }

        foreach ($attempts as $attempt) {
            if ($attempt->Status === 'Success') {
                return false;
            }
        }

        // Calculate effective LockedOutUntil
        /** @var DBDatetime $firstFailureDate */
        $firstFailureDate = $attempts->first()->dbObject('Created');
        $maxAgeSeconds = $this->config()->get('lock_out_delay_mins') * 60;
        $lockedOutUntil = $firstFailureDate->getTimestamp() + $maxAgeSeconds;
        $now = DBDatetime::now()->getTimestamp();
        if ($now < $lockedOutUntil) {
            return true;
        }

        return false;
    }
381362
def lock(self):
    """"""
    if hasattr(self, 'session'):
      raise RuntimeError('Dead lock detected. Please do not try to lock the session when it is already locked!')

    if LooseVersion(sqlalchemy.__version__) < LooseVersion('0.7.8'):
      # for old sqlalchemy versions, in some cases it is required to re-generate the engine for each session
      self._engine = sqlalchemy.create_engine("sqlite:///"+self._database)
      self._session_maker = sqlalchemy.orm.sessionmaker(bind=self._engine)

    # create the database if it does not exist yet
    if not os.path.exists(self._database):
      self._create()

    # now, create a session
    self.session = self._session_maker()
    logger.debug("Created new database session to '%s'" % self._database)
    return self.session
5676
private function lockColumnsExist(Connection $db)
    {
        $schema = $db->getSchemaManager()->listTableColumns($this->table);
        return isset($schema['lockid']);
    }
225799
public function lock($tables) {
        $lock = '';
        foreach (explode(',', $tables) as $tab) {
            $lock .= tablename(trim($tab)) . " WRITE,";
        }
        return $this->execute("LOCK TABLES " . substr($lock, 0, -1));
    }
914196
public function lock()
    {
        if (!$this->isLocked()) {
            $file = fopen($this->getFilePath(), 'w');
            if ($file) {
                fwrite($file, getmypid());
                fclose($file);
                return true;
            }
        }
        return false;
    }
1131265
public boolean lock(boolean shared, boolean block)
  {
    if (shared && !_canRead) {
      // Invalid request for a shared "read" lock on a write only stream.

      return false;
    }

    if (!shared && !_canWrite) {
      // Invalid request for an exclusive "write" lock on a read only stream.

      return false;
    }

    return true;
  }
809709
def trylock(self):
        ""
        if self.locked:
            return True
        if self.lockroutine:
            return False
        waiter = self.scheduler.send(LockEvent(self.context, self.key, self))
        if waiter:
            return False
        else:
            self.locked = True
            return True
1335611
private final void contendedLock() {
            boolean waiting = false;
            for (int s;;) {
                if (((s = lockState) & ~WAITER) == 0) {
                    if (U.compareAndSwapInt(this, LOCKSTATE, s, WRITER)) {
                        if (waiting)
                            waiter = null;
                        return;
                    }
                }
                else if ((s & WAITER) == 0) {
                    if (U.compareAndSwapInt(this, LOCKSTATE, s, s | WAITER)) {
                        waiting = true;
                        waiter = Thread.currentThread();
                    }
                }
                else if (waiting)
                    LockSupport.park(this);
            }
        }
468933
def __initLock(self):
        """"""
        self._isLocked = False
        self._timer = 0
        self._operation = False
301821
private synchronized final boolean isStateLocked()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            SibTr.entry(this, tc, "isStateLocked");
            SibTr.exit(this, tc, "isStateLocked", _itemLinkState);
        }
        if (_itemLinkState == ItemLinkState.STATE_LOCKED)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
519832
function lock()
    {
        if ( $fp = $this->fp() )
        {
            if ( flock( $fp, LOCK_EX ) )
            {
                $this->clearMeta();
                $this->setMeta( 'timestamp', time() );
                return true;
            }
        }
        return false;
    }
394140
def _lock(self):
        '''
        
        '''
        if not self._is_locked():
            with open(self._lck,'w') as fh:
                if self._devel: self.logger.debug("Locking")
                fh.write(str(os.getpid()))
            return True
        else:
            return False
34234
protected function lock()
    {
        $this->tables->execute();
        $table = array();

        while ($a = $this->tables->fetch(\PDO::FETCH_ASSOC)) {
            $table[] = current($a);
        }

        return !$table || $this->pdo->exec('LOCK TABLES `'.implode('` WRITE, `', $table).'` WRITE');
    }
1084427
public function lock()
    {
        if ($this->status !== self::BUSY) {
            throw new \LogicException('Cannot lock a slave that is not in busy state');
        }

        $this->status = self::LOCKED;
    }
51522
public synchronized void unlock()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "unlock", this);

    // If the subscription locks are down to zero then notify the threads waiting
    // for the subscriptionTable lock.
    synchronized (iMutex)
    {
      if (readLockCount == 0)
      {
        if (tc.isEntryEnabled()) 
          SibTr.exit(tc, "unlock", "SIErrorException");
        
        SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
          new Object[] {
            "com.ibm.ws.sib.processor.utils.AdvancedLockManager",
            "1:237:1.3" });
          
        throw new SIErrorException(
          nls.getFormattedMessage(
            "INTERNAL_MESSAGING_ERROR_CWSIP0001",
            new Object[] {
              "com.ibm.ws.sib.processor.utils.AdvancedLockManager",
              "1:244:1.3" },
            null));
      }
      
      decrementThreadLockCount();
      // Decrement the lock count and notify the other threads if no 
      // one holds the lock any more.
      if (readLockCount == 0)
        notifyAll();        
    }

    if (tc.isEntryEnabled())
      SibTr.exit(tc, "unlock");
  }
901028
def unlock(self):
        
        cursor = connection.cursor()
        cursor.execute("UNLOCK TABLES")
        logger.debug('Unlocked tables')
        row = cursor.fetchone()
        return row