comparison org.eclipse.core.jobs/src/org/eclipse/core/runtime/jobs/LockListener.d @ 12:bc29606a740c

Added dwt-addons in original directory structure of eclipse.org
author Frank Benoit <benoit@tionex.de>
date Sat, 14 Mar 2009 18:23:29 +0100
parents
children 52184e4b815c
comparison
equal deleted inserted replaced
11:43904fec5dca 12:bc29606a740c
1 /*******************************************************************************
2 * Copyright (c) 2004, 2006 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM - Initial API and implementation
10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13 module org.eclipse.core.runtime.jobs.LockListener;
14
15 import java.lang.JThread;
16 import java.lang.all;
17 import java.util.Set;
18
19 import org.eclipse.core.internal.jobs.JobManager;
20 import org.eclipse.core.internal.jobs.LockManager;
21 import org.eclipse.core.runtime.jobs.Job;
22
23 /**
24 * A lock listener is notified whenever a thread is about to wait
25 * on a lock, and when a thread is about to release a lock.
26 * <p>
27 * This class is for internal use by the platform-related plug-ins.
28 * Clients outside of the base platform should not reference or subclass this class.
29 * </p>
30 *
31 * @see IJobManager#setLockListener(LockListener)
32 * @since 3.0
33 */
34 public class LockListener {
35 private const LockManager manager;
36
37 public this(){
38 manager = (cast(JobManager)Job.getJobManager()).getLockManager();
39 }
40
41 /**
42 * Notification that a thread is about to block on an attempt to acquire a lock.
43 * Returns whether the thread should be granted immediate access to the lock.
44 * <p>
45 * This default implementation always returns <code>false</code>.
46 * Subclasses may override.
47 *
48 * @param lockOwner the thread that currently owns the lock this thread is
49 * waiting for, or <code>null</code> if unknown.
50 * @return <code>true</code> if the thread should be granted immediate access,
51 * and <code>false</code> if it should wait for the lock to be available
52 */
53 public bool aboutToWait(JThread lockOwner) {
54 return false;
55 }
56
57 /**
58 * Notification that a thread is about to release a lock.
59 * <p>
60 * This default implementation does nothing. Subclasses may override.
61 */
62 public void aboutToRelease() {
63 //do nothing
64 }
65
66 /**
67 * Returns whether this thread currently owns any locks
68 * @return <code>true</code> if this thread owns any locks, and
69 * <code>false</code> otherwise.
70 */
71 protected final bool isLockOwnerThread() {
72 return manager.isLockOwner();
73 }
74 }