001    package edu.rice.cs.cunit.record.syncPoints.object;
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.ISyncPointVisitor;
006    import edu.rice.cs.cunit.instrumentors.DoNotInstrument;
007    
008    /**
009     * Synchronization point corresponding to the end of an Object.wait call.
010     *
011     * @author Mathias Ricken
012     */
013    @DoNotInstrument
014    public class ObjectLeaveWaitSyncPoint extends AObjectSyncPoint {
015        /**
016         * Timeout duration.
017         */
018        private long _timeOut;
019    
020        /**
021         * Constructor for this synchronization point.
022         * @param object object whose wait method ended.
023         * @param timeOut timeout duration
024         * @param thread current thread
025         */
026        public ObjectLeaveWaitSyncPoint(Object object, long timeOut, Thread thread) {
027            super(object, thread);
028            _timeOut = timeOut;
029        }
030    
031        /**
032         * Class for translated versions on the monitor side.
033         */
034        public static class Translated extends AObjectSyncPoint.Translated {
035            /**
036             * Timeout duration.
037             */
038            private long _timeOut;
039    
040            /**
041             * Constructor for translated version on the monitor side.
042             * @param object info about the object
043             * @param timeOut timeout duration
044             * @param thread info about the current thread
045             */
046            public Translated(LockInfo object, long timeOut, ThreadInfo thread) {
047                super(object, thread);
048                _timeOut = timeOut;
049            }
050    
051            /**
052             * Executes a visitor.
053             *
054             * @param visitor visitor to execute
055             * @param param   visitor-specific parameter
056             *
057             * @return visitor-specific return value
058             */
059            public <R,P> R execute(ISyncPointVisitor<R, P> visitor, P param) {
060                return visitor.objectWaitEndCase(this, param);
061            }
062    
063            /**
064             * Returns the timeout duration.
065             * @return timeout duration
066             */
067            public long getTimeOut() {
068                return _timeOut;
069            }
070    
071            /**
072             * Returns a string representation of the object.
073             * @return a string representation of the object.
074             */
075            public String toString() {
076                return super.toString()+" timeOut="+_timeOut;
077            }
078        }
079    }