[jboss-svn-commits] JBL Code SVN: r30064 - labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Nov 6 14:25:43 EST 2009


Author: mark.little at jboss.com
Date: 2009-11-06 14:25:42 -0500 (Fri, 06 Nov 2009)
New Revision: 30064

Added:
   labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockList.java
   labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockListIterator.java
Removed:
   labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockList.java
   labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockListIterator.java
Modified:
   labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockConflictManager.java
Log:
https://jira.jboss.org/jira/browse/JBTM-639

Modified: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockConflictManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockConflictManager.java	2009-11-06 16:50:40 UTC (rev 30063)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockConflictManager.java	2009-11-06 19:25:42 UTC (rev 30064)
@@ -37,109 +37,108 @@
 import java.lang.InterruptedException;
 
 /**
- * An instance of this class is used to determine what to do in the
- * event of a lock conflict for a given object. If the timeout and
- * retry values are >=0 then we use them to sleep the thread which tried
- * to get the lock. If the retry value is -100 (LockManager.waitTotalTimeout)
- * then the thread will block for up to the total timeout and be signalled
- * either when the timeout occurs, or when the lock is actually released.
+ * An instance of this class is used to determine what to do in the event of a
+ * lock conflict for a given object. If the timeout and retry values are >=0
+ * then we use them to sleep the thread which tried to get the lock. If the
+ * retry value is -100 (LockManager.waitTotalTimeout) then the thread will block
+ * for up to the total timeout and be signalled either when the timeout occurs,
+ * or when the lock is actually released.
  */
 
 class LockConflictManager
 {
 
-LockConflictManager ()
+    LockConflictManager()
     {
-	_lock = new Object();
-	_signals = 0;
+        _lock = new Object();
+        _signals = 0;
     }
 
     /**
-     * Wait for the specified timeout and retry. We may either sleep the
-     * thread, or block it on a mutex.
-     *
-     * Returns the time taken to wait.
+     * Wait for the specified timeout and retry. We may either sleep the thread,
+     * or block it on a mutex. Returns the time taken to wait.
      */
 
-int wait (int retry, int waitTime)
+    int wait (int retry, int waitTime)
     {
-	/*
-	 * If the retry is -1 then we wait on the object as if it
-	 * were a lock. Otherwise we do the usual sleep call.
-	 */
+        /*
+         * If the retry is -1 then we wait on the object as if it were a lock.
+         * Otherwise we do the usual sleep call.
+         */
 
-	if (retry < 0)
-	{
-	    /*
-	     * Wait for the lock object to be signalled.
-	     */
+        if (retry < 0)
+        {
+            /*
+             * Wait for the lock object to be signalled.
+             */
 
-	    Date d1 = Calendar.getInstance().getTime();
-	    
-	    synchronized (_lock)
-		{
-		    try
-		    {
-			/*
-			 * Consume an old signal. May cause us to go round
-			 * the loop quicker than we should, but its better
-			 * than synchronizing signal and wait.
-			 */
+            Date d1 = Calendar.getInstance().getTime();
 
-			if (_signals == 0)
-			{
-			    _lock.wait(waitTime);
-			}
-			else
-			{
-			    _signals--;
+            synchronized (_lock)
+            {
+                try
+                {
+                    /*
+                     * Consume an old signal. May cause us to go round the loop
+                     * quicker than we should, but its better than synchronizing
+                     * signal and wait.
+                     */
 
-			    return waitTime;
-			}
-		    }
-		    catch (InterruptedException e)
-		    {
-		    }
-		}
+                    if (_signals == 0)
+                    {
+                        _lock.wait(waitTime);
+                    }
+                    else
+                    {
+                        _signals--;
 
-	    Date d2 = Calendar.getInstance().getTime();
+                        return waitTime;
+                    }
+                }
+                catch (InterruptedException e)
+                {
+                }
+            }
 
-	    return (int) (d2.getTime() - d1.getTime());
-	}
-	else
-	{
-	    try
-	    {
-		/* hope things happen in time */
-	    
-		Thread.sleep(waitTime);
-	    }
-	    catch (InterruptedException e)
-	    {
-	    }
+            Date d2 = Calendar.getInstance().getTime();
 
-	    return 0;
-	}
-    }    
+            return (int) (d2.getTime() - d1.getTime());
+        }
+        else
+        {
+            try
+            {
+                /* hope things happen in time */
 
+                Thread.sleep(waitTime);
+            }
+            catch (InterruptedException e)
+            {
+            }
+
+            return 0;
+        }
+    }
+
     /**
      * Signal that the lock has been released.
      */
-    
-void signal ()
+
+    void signal ()
     {
-	synchronized (_lock)
-	    {
-		_lock.notifyAll();
+        synchronized (_lock)
+        {
+            _lock.notifyAll();
 
-		_signals++;
+            _signals++;
 
-		if (_signals < 0)  // check for overflow
-		    _signals = 1;
-	    }
+            if (_signals < 0) // check for overflow
+                _signals = 1;
+        }
     }
-    
-private Object _lock;
-private int    _signals;
-    
+
+    private Object _lock;
+
+    private int _signals;
+
 }

Deleted: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockList.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockList.java	2009-11-06 16:50:40 UTC (rev 30063)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockList.java	2009-11-06 19:25:42 UTC (rev 30064)
@@ -1,151 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors 
- * as indicated by the @author tags. 
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.  
- *
- * $Id: LockList.java 2342 2006-03-30 13:06:17Z  $
- */
-
-package com.arjuna.ats.txoj;
-
-public class LockList
-{
-
-public LockList ()
-    {
-	count = 0;
-	head = null;
-    }
-
-public void finalize ()
-    {
-	Lock temp = null;
-
-	while ((temp = pop()) != null)
-	    temp = null;  // temp.finalize() ?
-    }
-
-    /*
-     * Insert a new Lock. This returns TRUE if the insertion occurred, false
-     * otherwise. Insertion fails if a matching lock already exists in the
-     * list.
-     */
-
-public final boolean insert (Lock newlock)
-    {
-	LockListIterator next = new LockListIterator(this);
-	Lock current = null;
-
-	while ((current = next.iterate()) != null)
-	{
-	    if (current.equals(newlock))
-	    {
-		return false;
-	    }
-	}
-
-	push(newlock);
-	
-	return true;
-    }
-
-    /*
-     * Pop the first element off the list and return it.
-     */
-
-public final Lock pop ()
-    {
-	Lock current;
-
-	if (count == 0)
-	    return null;
-
-	current = (Lock) head;
-	count--;
-	head = head.getLink();
-	current.setLink(null);
-	
-	return current;
-    }
-
-    /*
-     *  Push a new element at the head of the list. First set the link
-     *  field to be the old head, and then set head to be the new element.
-     */
-
-public final void push (Lock newLock)
-    {
-	newLock.setLink(head);
-	head = newLock;
-	count++;
-    }
-
-    /*
-     * Discard the element following the one pointed at. If it is the
-     * first element (current = 0) then simply change the head pointer.
-     * Beware if current points at the last element or the list is empty!
-     * This probably indicates a bug in the caller.
-     */
-
-public final void forgetNext (Lock current)
-    {
-	if (count > 0)			/* something there to forget */
-	{
-	    if (current == null)
-		head = head.getLink();
-	    else
-	    {
-		Lock nextOne = current.getLink();
-	    
-		/* See if at list end */
-
-		if (nextOne != null)
-		    current.setLink(nextOne.getLink());
-		else
-		{
-		    /*
-		     * Probably an error - being asked to forget element
-		     * after end of list
-		     */
-		    count++;
-		    current.setLink(null);	/* force end of list */
-		}
-	    }
-	    
-	    count--;
-	}
-    }
-
-public final int entryCount ()
-    {
-	return count;
-    }
-
-protected Lock head;
-    
-private int count;
-    
-}

Added: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockList.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockList.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockList.java	2009-11-06 19:25:42 UTC (rev 30064)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors 
+ * as indicated by the @author tags. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 1998, 1999, 2000,
+ *
+ * Arjuna Solutions Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.  
+ *
+ * $Id: LockList.java 2342 2006-03-30 13:06:17Z  $
+ */
+
+package com.arjuna.ats.txoj;
+
+
+public class LockList
+{
+
+    public LockList()
+    {
+        count = 0;
+        head = null;
+    }
+
+    public void finalize ()
+    {
+        Lock temp = null;
+
+        while ((temp = pop()) != null)
+            temp = null; // temp.finalize() ?
+    }
+
+    /*
+     * Insert a new Lock. This returns TRUE if the insertion occurred, false
+     * otherwise. Insertion fails if a matching lock already exists in the list.
+     */
+
+    public final boolean insert (Lock newlock)
+    {
+        LockListIterator next = new LockListIterator(this);
+        Lock current = null;
+
+        while ((current = next.iterate()) != null)
+        {
+            if (current.equals(newlock))
+            {
+                return false;
+            }
+        }
+
+        push(newlock);
+
+        return true;
+    }
+
+    /*
+     * Pop the first element off the list and return it.
+     */
+
+    public final Lock pop ()
+    {
+        Lock current;
+
+        if (count == 0)
+            return null;
+
+        current = (Lock) head;
+        count--;
+        head = head.getLink();
+        current.setLink(null);
+
+        return current;
+    }
+
+    /*
+     * Push a new element at the head of the list. First set the link field to
+     * be the old head, and then set head to be the new element.
+     */
+
+    public final void push (Lock newLock)
+    {
+        newLock.setLink(head);
+        head = newLock;
+        count++;
+    }
+
+    /*
+     * Discard the element following the one pointed at. If it is the first
+     * element (current = 0) then simply change the head pointer. Beware if
+     * current points at the last element or the list is empty! This probably
+     * indicates a bug in the caller.
+     */
+
+    public final void forgetNext (Lock current)
+    {
+        if (count > 0) /* something there to forget */
+        {
+            if (current == null)
+                head = head.getLink();
+            else
+            {
+                Lock nextOne = current.getLink();
+
+                /* See if at list end */
+
+                if (nextOne != null)
+                    current.setLink(nextOne.getLink());
+                else
+                {
+                    /*
+                     * Probably an error - being asked to forget element after
+                     * end of list
+                     */
+                    count++;
+                    current.setLink(null); /* force end of list */
+                }
+            }
+
+            count--;
+        }
+    }
+
+    public final int entryCount ()
+    {
+        return count;
+    }
+
+    protected Lock head;
+
+    private int count;
+
+}

Deleted: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockListIterator.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockListIterator.java	2009-11-06 16:50:40 UTC (rev 30063)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockListIterator.java	2009-11-06 19:25:42 UTC (rev 30064)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors 
- * as indicated by the @author tags. 
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.  
- *
- * $Id: LockListIterator.java 2342 2006-03-30 13:06:17Z  $
- */
-
-package com.arjuna.ats.txoj;
-
-public class LockListIterator
-{
-
-    public LockListIterator(LockList L)
-    {
-        currentList = L;
-        next = currentList.head;
-    }
-
-    public final synchronized Lock iterate ()
-    {
-        Lock current = next;
-
-        if (current == null)
-        {
-            return null;
-        }
-        else
-            next = current.getLink();
-
-        return current;
-    }
-
-    public final synchronized void reset ()
-    {
-        next = null;
-    }
-
-    private LockList currentList;
-
-    private Lock next;
-
-}

Added: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockListIterator.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockListIterator.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockListIterator.java	2009-11-06 19:25:42 UTC (rev 30064)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors 
+ * as indicated by the @author tags. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 1998, 1999, 2000,
+ *
+ * Arjuna Solutions Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.  
+ *
+ * $Id: LockListIterator.java 2342 2006-03-30 13:06:17Z  $
+ */
+
+package com.arjuna.ats.txoj;
+
+
+public class LockListIterator
+{
+
+    public LockListIterator(LockList L)
+    {
+        currentList = L;
+        next = currentList.head;
+    }
+
+    public final synchronized Lock iterate ()
+    {
+        Lock current = next;
+
+        if (current == null)
+        {
+            return null;
+        }
+        else
+            next = current.getLink();
+
+        return current;
+    }
+
+    public final synchronized void reset ()
+    {
+        next = null;
+    }
+
+    private LockList currentList;
+
+    private Lock next;
+
+}



More information about the jboss-svn-commits mailing list