/*
 * Copyright 2000-2015 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.jetbrains.python.debugger;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;


public abstract class PyConcurrencyEvent {
  protected final @NotNull String myThreadId;
  protected final @NotNull String myName;
  protected @NotNull EventType myType;
  protected @NotNull String myFileName;
  protected @NotNull Integer myLine;
  protected final boolean myIsAsyncio;
  protected final long myTime;
  protected @NotNull List<PyStackFrameInfo> myFrames;

  public enum EventType {
    CREATE, ACQUIRE_BEGIN, ACQUIRE_END, RELEASE, START, JOIN, STOP
  }

  public PyConcurrencyEvent(long time, @NotNull String threadId, @NotNull String name, boolean isAsyncio) {
    myTime = time;
    myThreadId = threadId;
    myName = name;
    myIsAsyncio = isAsyncio;
    myType = EventType.CREATE;
    myFileName = "";
    myLine = 0;
    myFrames = new ArrayList<PyStackFrameInfo>();
  }

  public void setType(@NotNull EventType type) {
    myType = type;
  }

  @NotNull
  public String getThreadId() {
    return myThreadId;
  }

  @NotNull
  public EventType getType() {
    return myType;
  }

  @NotNull
  public String getThreadName() {
    return myName;
  }

  @NotNull
  public abstract String getEventActionName();

  public abstract boolean isThreadEvent();

  public void setFileName(@NotNull String fileName) {
    myFileName = fileName;
  }

  @NotNull
  public String getFileName() {
    return myFileName;
  }

  public void setLine(@NotNull Integer line) {
    myLine = line;
  }

  public long getTime() {
    return myTime;
  }

  @NotNull
  public Integer getLine() {
    return myLine;
  }

  @NotNull
  public List<PyStackFrameInfo> getFrames() {
    return myFrames;
  }

  public void setFrames(@NotNull List<PyStackFrameInfo> frames) {
    myFrames = frames;
  }

  public boolean isAsyncio() {
    return myIsAsyncio;
  }
}

@@ -819,16 +819,57 @@
 readId;%0A
+  protected final @NotNull String myPid;%0A
   protec
@@ -1069,22 +1069,16 @@
 otected 
-final 
 long myT
@@ -1081,16 +1081,32 @@
  myTime;
+ // microseconds
 %0A  prote
@@ -1405,16 +1405,52 @@
 readId;%0A
+    myPid = threadId.split(%22_%22)%5B0%5D;%0A
     myNa
@@ -2278,63 +2278,183 @@
 %0A%0A  
-@NotNull%0A  public Integer getLine() %7B%0A    return myLine
+public void setTime(long time) %7B%0A    myTime = time;%0A  %7D%0A%0A  @NotNull%0A  public Integer getLine() %7B%0A    return myLine;%0A  %7D%0A%0A  @NotNull%0A  public String getPid() %7B%0A    return myPid
 ;%0A  

Fix graph drawing for multiprocess programs (PY-17268)