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 the end of a Thread.sleep call.
009     *
010     * @author Mathias Ricken
011     */
012    @DoNotInstrument
013    public class ThreadLeaveSleepSyncPoint extends AThreadSyncPoint {
014        /**
015         * Duration of sleep.
016         */
017        private long _duration;
018    
019        /**
020         * Constructor for this synchronization point.
021         * @param thread current thread
022         * @param duration duration of sleep
023         */
024        public ThreadLeaveSleepSyncPoint(Thread thread, long duration) {
025            super(thread);
026            _duration = duration;
027        }
028    
029        /**
030         * Class for translated versions on the monitor side.
031         */
032        public static class Translated extends AThreadSyncPoint.Translated {
033            /**
034             * Duration of sleep.
035             */
036            private long _duration;
037    
038            /**
039             * Constructor for translated version on the monitor side.
040             * @param thread current thread
041             * @param duration duration of sleep
042             */
043            public Translated(ThreadInfo thread, long duration) {
044                super(thread);
045                _duration = duration;
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.threadSleepEndCase(this, param);
058            }
059    
060            /**
061             * Returns the duration of the sleep
062             * @return duration
063             */
064            public long getDuration() {
065                return _duration;
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()+" duration="+_duration;
074            }
075        }
076    }