<?php
/**
+ * @defgroup LockManager Lock management
+ * @ingroup FileBackend
+ */
+
+/**
+ * Resource locking handling.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
* @file
* @ingroup LockManager
* @author Aaron Schulz
*/
/**
- * Class for handling resource locking.
+ * @brief Class for handling resource locking.
+ *
* Locks on resource keys can either be shared or exclusive.
- *
+ *
* Implementations must keep track of what is locked by this proccess
* in-memory and support nested locking calls (using reference counting).
* At least LOCK_UW and LOCK_EX must be implemented. LOCK_SH can be a no-op.
* Locks should either be non-blocking or have low wait timeouts.
- *
+ *
* Subclasses should avoid throwing exceptions at all costs.
*
* @ingroup LockManager
* @return Status
*/
final public function lock( array $paths, $type = self::LOCK_EX ) {
- return $this->doLock( array_unique( $paths ), $this->lockTypeMap[$type] );
+ wfProfileIn( __METHOD__ );
+ $status = $this->doLock( array_unique( $paths ), $this->lockTypeMap[$type] );
+ wfProfileOut( __METHOD__ );
+ return $status;
}
/**
* @return Status
*/
final public function unlock( array $paths, $type = self::LOCK_EX ) {
- return $this->doUnlock( array_unique( $paths ), $this->lockTypeMap[$type] );
+ wfProfileIn( __METHOD__ );
+ $status = $this->doUnlock( array_unique( $paths ), $this->lockTypeMap[$type] );
+ wfProfileOut( __METHOD__ );
+ return $status;
}
/**
}
/**
+ * Self releasing locks
+ *
* LockManager helper class to handle scoped locks, which
* release when an object is destroyed or goes out of scope.
*
protected function __construct(
LockManager $manager, array $paths, $type, Status $status
) {
- $this->manager = $manager;
- $this->paths = $paths;
- $this->status = $status;
- $this->type = $type;
+ $this->manager = $manager;
+ $this->paths = $paths;
+ $this->status = $status;
+ $this->type = $type;
}
- protected function __clone() {}
-
/**
* Get a ScopedLock object representing a lock on resource paths.
* Any locks are released once this object goes out of scope.
* @since 1.19
*/
class NullLockManager extends LockManager {
+ /**
+ * @see LockManager::doLock()
+ * @param $paths array
+ * @param $type int
+ * @return Status
+ */
protected function doLock( array $paths, $type ) {
return Status::newGood();
}
+ /**
+ * @see LockManager::doUnlock()
+ * @param $paths array
+ * @param $type int
+ * @return Status
+ */
protected function doUnlock( array $paths, $type ) {
return Status::newGood();
}