001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.lock;
020
021
022/**
023 * Manager to open and close locks
024 */
025public interface LockManager {
026
027    /**
028     * Field <code>TYPE_READONLY</code>
029     */
030    public static final int TYPE_READONLY = 0;
031
032    /**
033     * Field <code>TYPE_EXCLUSIVE</code>
034     */
035    public static final int TYPE_EXCLUSIVE = 1;
036
037    /**
038     * locks a thread if already a other thread is come 
039     * until other thread notify him by unlock method
040     * @param type 
041     * @param name Lock Name (not case sensitive)
042     * @param timeout tiemout to for waiting in this method, if timeout occurs "lockTiemoutException" will be throwd
043     * @param pageContextId 
044     * @return  lock data object key for unlocking this lock
045     * @throws LockTimeoutException
046     * @throws InterruptedException
047     */
048    public abstract LockData lock(int type, String name, int timeout,
049            int pageContextId) throws LockTimeoutException,
050            InterruptedException;
051
052    /**
053     * unlocks a locked thread in lock method
054     * @param data 
055     */
056    public abstract void unlock(LockData data);
057    
058    public String[] getOpenLockNames();
059    
060
061        public abstract void clean();
062
063}