1 /*
   2  * Copyright (c) 2014, 2015, Dynatrace and/or its affiliates. All rights reserved.
   3  * 
   4  * This file is part of the Lock Contention Tracing Subsystem for the HotSpot
   5  * Virtual Machine, which is developed at Christian Doppler Laboratory on
   6  * Monitoring and Evolution of Very-Large-Scale Software Systems. Please
   7  * contact us at <http://mevss.jku.at/> if you need additional information
   8  * or have any questions.
   9  *
  10  * This code is free software; you can redistribute it and/or modify it
  11  * under the terms of the GNU General Public License version 2 only, as
  12  * published by the Free Software Foundation.
  13  *
  14  * This code is distributed in the hope that it will be useful, but WITHOUT
  15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  17  * version 2 for more details (a copy is included in the LICENSE file that
  18  * accompanied this code).
  19  *
  20  * You should have received a copy of the GNU General Public License version
  21  * 2 along with this work. If not, see <http://www.gnu.org/licenses/>.
  22  *
  23  */ 
  24 package sun.evtracing.parser;
  25 
  26 import sun.evtracing.parser.TraceEventType;
  27 import sun.evtracing.processing.TraceEventHandler;
  28 
  29 public class ThreadParkEndEvent extends GlobalSequenceOrderedEvent {
  30 
  31         public static final TraceEventType EVENT_TYPE = TraceEventType.ThreadParkEnd;
  32 
  33         public static ThreadParkEndEvent parse(TraceReader reader, long thread) {
  34                 TraceEventType eventType = reader.readEventType();
  35                 assert eventType == EVENT_TYPE;
  36                 long timestamp = reader.readTimestamp();
  37                 long sequenceNumber = reader.readSequenceNumber();
  38                 long unparkSequenceNumber = reader.readSequenceNumber();
  39                 ParkReturnCode parkReturnCode = reader.readParkReturnCode();
  40                 return new ThreadParkEndEvent(thread, timestamp, sequenceNumber, unparkSequenceNumber, parkReturnCode);
  41         }
  42 
  43         private final long unparkSequenceNumber;
  44         private final ParkReturnCode parkReturnCode;
  45 
  46         protected ThreadParkEndEvent(long thread, long timestamp, long sequenceNumber, long unparkSequenceNumber, ParkReturnCode parkReturnCode) {
  47                 super(thread, timestamp, sequenceNumber);
  48                 this.unparkSequenceNumber = unparkSequenceNumber;
  49                 this.parkReturnCode = parkReturnCode;
  50         }
  51 
  52         @Override
  53         public TraceEventType type() {
  54                 return EVENT_TYPE;
  55         }
  56 
  57         public long unparkSequenceNumber() {
  58                 return unparkSequenceNumber;
  59         }
  60 
  61         public ParkReturnCode parkReturnCode() {
  62                 return parkReturnCode;
  63         }
  64 
  65         @Override
  66         public void accept(TraceEventHandler handler) {
  67                 handler.threadParkEnd(this);
  68         }
  69 }