KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > perseus > concurrency > distributed > globallock > Upgrade


1 /**
2  * Copyright (C) 2003-2004
3  * - France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR AE PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Release: 1.0
20  *
21  * Authors: Olivier Lobry (olivier.lobry@rd.francetelecom.com)
22  *
23  */

24
25 package org.objectweb.perseus.concurrency.distributed.globallock;
26
27 import org.objectweb.perseus.concurrency.distributed.AbstractLockingAction;
28 import org.objectweb.perseus.concurrency.distributed.globallock.api.GlobalLock;
29
30 public class Upgrade extends AbstractLockingAction {
31     GlobalLockInterceptor h;
32     boolean waitNotGrantable;
33
34     public Upgrade(GlobalLockInterceptor h, byte expBehaviour,
35                      byte execMode, byte lck, boolean waitNotGrantable) {
36         super(h.getName(), expBehaviour, execMode, lck);
37         this.h = h;
38         this.waitNotGrantable = waitNotGrantable;
39     }
40
41
42     protected void performBlockingAction() throws Exception JavaDoc {
43
44         if (waitNotGrantable)
45             while (h.getGrantable() >= lck) Thread.sleep(100);
46
47         /* GlobalLockWaiterImpl w = h.upgrade(lck, false); */
48         h.upgrade(lck, true, 0);
49 /* handledByUser();
50         if (w != null) {
51             boolean ok = w.waitLock(0);
52             if (!ok) {
53                 if (h.trace) h.trace("WAKE UP TIMED OUT (Waiting: " + lck + ")");
54                 te.addException(new DeadLockException());
55             }
56             if (h.trace) h.trace("WAKE UP (Waiting: " + lck + ")");
57             return;
58         }
59         */

60     }
61
62         final public String JavaDoc getBrief() {
63             return "U";
64         }
65
66         protected String JavaDoc getLockingDescription() {
67             return "upgrade";
68         }
69
70 }
71
Popular Tags