001 package edu.rice.cs.cunit.record.syncPoints.thread;
002
003 import edu.rice.cs.cunit.record.graph.ThreadInfo;
004 import edu.rice.cs.cunit.record.syncPoints.ISyncPointVisitor;
005 import edu.rice.cs.cunit.instrumentors.DoNotInstrument;
006
007 /**
008 * Synchronization point corresponding to a Thread.setPriority call.
009 *
010 * @author Mathias Ricken
011 */
012 @DoNotInstrument
013 public class ThreadSetPrioritySyncPoint extends AThreadSyncPoint {
014 /**
015 * New priority that was set.
016 */
017 private int _newPriority;
018
019 /**
020 * Constructor for this synchronization point.
021 * @param thread thread whose setPriority method was called.
022 * @param newPriority new priority that was set
023 */
024 public ThreadSetPrioritySyncPoint(Thread thread, int newPriority) {
025 super(thread);
026 _newPriority = newPriority;
027 }
028
029 /**
030 * Class for translated versions on the monitor side.
031 */
032 public static class Translated extends AThreadSyncPoint.Translated {
033 /**
034 * New priority that was set.
035 */
036 private int _newPriority;
037
038 /**
039 * Constructor for translated version on the monitor side.
040 * @param threadInfo info about the thread
041 * @param newPriority new priority that was set
042 */
043 public Translated(ThreadInfo threadInfo, int newPriority) {
044 super(threadInfo);
045 _newPriority = newPriority;
046 }
047
048 /**
049 * Executes a visitor.
050 *
051 * @param visitor visitor to execute
052 * @param param visitor-specific parameter
053 *
054 * @return visitor-specific return value
055 */
056 public <R,P> R execute(ISyncPointVisitor<R, P> visitor, P param) {
057 return visitor.threadSetPriorityCase(this, param);
058 }
059
060 /**
061 * Returns the new priority that was set.
062 * @return new priority
063 */
064 public int getNewPriority() {
065 return _newPriority;
066 }
067
068 /**
069 * Returns a string representation of the object.
070 * @return a string representation of the object.
071 */
072 public String toString() {
073 return super.toString()+" newPriority="+_newPriority;
074 }
075 }
076 }