001 package edu.rice.cs.cunit.record.syncPoints.sync;
002
003 import edu.rice.cs.cunit.record.graph.LockInfo;
004 import edu.rice.cs.cunit.record.graph.ThreadInfo;
005 import edu.rice.cs.cunit.record.syncPoints.ISyncPoint;
006 import edu.rice.cs.cunit.instrumentors.DoNotInstrument;
007
008 /**
009 * General class for synchronized object-related synchronization points.
010 * @author Mathias Ricken
011 */
012 @DoNotInstrument
013 public abstract class ASynchronizedObjectSyncPoint implements ISyncPoint {
014 /**
015 * Object whose lock was acquired.
016 */
017 protected final Object _object;
018
019 /**
020 * Thread which acquired the lock.
021 */
022 protected final Thread _thread;
023
024 /**
025 * Constructor for this synchronization point.
026 * @param object object whose lock was acquired.
027 * @param thread thread that acquired the lock.
028 */
029 public ASynchronizedObjectSyncPoint(Object object, Thread thread) {
030 _object = object;
031 _thread = thread;
032 }
033
034 /**
035 * Class for translated versions on the monitor side.
036 */
037 public static abstract class Translated implements ISyncPoint.Translated {
038 /**
039 * Info about the object.
040 */
041 LockInfo _lockInfo;
042
043 /**
044 * Info about the thread.
045 */
046 ThreadInfo _threadInfo;
047
048 /**
049 * Constructor for translated version on the monitor side.
050 * @param lockInfo info about the object
051 * @param threadInfo info about the thread
052 */
053 public Translated(LockInfo lockInfo, ThreadInfo threadInfo) {
054 _lockInfo = lockInfo;
055 _threadInfo = threadInfo;
056 }
057
058 /**
059 * Returns the info about the object.
060 * @return lock info
061 */
062 public LockInfo getLockInfo() {
063 return _lockInfo;
064 }
065
066 /**
067 * Returns the info about the thread.
068 * @return thread info
069 */
070 public ThreadInfo getThreadInfo() {
071 return _threadInfo;
072 }
073
074
075 /**
076 * Returns a string representation of the object.
077 * @return a string representation of the object.
078 */
079 public String toString() {
080 return this.getClass().getEnclosingClass().getSimpleName()+": LockInfo={"+_lockInfo+"} ThreadInfo={"+_threadInfo+"}";
081 }
082 }
083 }