// Path: src/main/java/com/zaxxer/nuprocess/windows/NuWinNT.java
// class HANDLE extends PointerType
// {
//    static final Pointer INVALID = Pointer.createConstant(Native.POINTER_SIZE == 8 ? -1 : 0xFFFFFFFFL);
// 
//    public HANDLE()
//    {
//    }
// 
//    public HANDLE(Pointer p)
//    {
//       setPointer(p);
//    }
// 
//    @Override
//    public Object fromNative(Object nativeValue, FromNativeContext context)
//    {
//       if (nativeValue == null) {
//          return null;
//       }
// 
//       Pointer ptr = (Pointer) nativeValue;
//       if (INVALID.equals(ptr)) {
//          return INVALID_HANDLE_VALUE;
//       }
//       return new HANDLE(ptr);
//    }
// }
// 
// Path: src/main/java/com/zaxxer/nuprocess/windows/NuWinNT.java
// class ULONG_PTR extends IntegerType
// {
//    public ULONG_PTR()
//    {
//       this(0);
//    }
// 
//    public ULONG_PTR(long value)
//    {
//       super(Native.POINTER_SIZE, value, true);
//    }
// }
// 
// Path: src/main/java/com/zaxxer/nuprocess/windows/NuWinNT.java
// class ULONG_PTRByReference extends ByReference
// {
//    public ULONG_PTRByReference()
//    {
//       this(new ULONG_PTR(0));
//    }
// 
//    public ULONG_PTRByReference(ULONG_PTR value)
//    {
//       super(Native.POINTER_SIZE);
//       setValue(value);
//    }
// 
//    public void setValue(ULONG_PTR value)
//    {
//       if (Native.POINTER_SIZE == 4) {
//          getPointer().setInt(0, value.intValue());
//       }
//       else {
//          getPointer().setLong(0, value.longValue());
//       }
//    }
// 
//    public ULONG_PTR getValue()
//    {
//       return new ULONG_PTR(Native.POINTER_SIZE == 4 ? getPointer().getInt(0) : getPointer().getLong(0));
//    }
// }
// 
// Path: src/main/java/com/zaxxer/nuprocess/windows/WindowsProcess.java
// static final class PipeBundle
// {
//    final OVERLAPPED overlapped;
//    final long ioCompletionKey;
//    final HANDLE pipeHandle;
//    ByteBuffer buffer;
//    boolean registered;
// 
//    PipeBundle(HANDLE pipeHandle, long ioCompletionKey)
//    {
//       this.pipeHandle = pipeHandle;
//       this.ioCompletionKey = ioCompletionKey;
// 
//       // The OVERLAPPED structure is required to make non-blocking ReadFile and WriteFile calls,
//       // but its state is never read from nor written to in Java, so we disable auto-sync so JNA
//       // doesn't waste time marshaling contents to/from native memory
//       overlapped = new OVERLAPPED();
//       overlapped.setAutoSynch(false);
//    }
// }


import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.sun.jna.Native;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.zaxxer.nuprocess.internal.Constants;
import com.zaxxer.nuprocess.windows.NuWinNT.HANDLE;
import com.zaxxer.nuprocess.windows.NuWinNT.ULONG_PTR;
import com.zaxxer.nuprocess.windows.NuWinNT.ULONG_PTRByReference;
import com.zaxxer.nuprocess.windows.WindowsProcess.PipeBundle;
      try {
         wantsWrite.put(process);
         NuKernel32.PostQueuedCompletionStatus(ioCompletionPort, 0, new ULONG_PTR(0), null);
      }
      catch (InterruptedException e) {
         // ignore
      }
   }

   void registerProcess(final WindowsProcess process)
   {
      if (shutdown) {
         return;
      }

      try {
         pendingPool.put(process);
         NuKernel32.PostQueuedCompletionStatus(ioCompletionPort, 0, new ULONG_PTR(0), null);
      }
      catch (InterruptedException e) {
         // ignore
      }
   }

   private void queueWrite(final WindowsProcess process)
   {
      if (shutdown) {
         return;
      }

// Path: src/main/java/com/zaxxer/nuprocess/windows/NuWinNT.java
// class HANDLE extends PointerType
// {
//    static final Pointer INVALID = Pointer.createConstant(Native.POINTER_SIZE == 8 ? -1 : 0xFFFFFFFFL);
// 
//    public HANDLE()
//    {
//    }
// 
//    public HANDLE(Pointer p)
//    {
//       setPointer(p);
//    }
// 
//    @Override
//    public Object fromNative(Object nativeValue, FromNativeContext context)
//    {
//       if (nativeValue == null) {
//          return null;
//       }
// 
//       Pointer ptr = (Pointer) nativeValue;
//       if (INVALID.equals(ptr)) {
//          return INVALID_HANDLE_VALUE;
//       }
//       return new HANDLE(ptr);
//    }
// }
// 
// Path: src/main/java/com/zaxxer/nuprocess/windows/NuWinNT.java
// class ULONG_PTR extends IntegerType
// {
//    public ULONG_PTR()
//    {
//       this(0);
//    }
// 
//    public ULONG_PTR(long value)
//    {
//       super(Native.POINTER_SIZE, value, true);
//    }
// }
// 
// Path: src/main/java/com/zaxxer/nuprocess/windows/NuWinNT.java
// class ULONG_PTRByReference extends ByReference
// {
//    public ULONG_PTRByReference()
//    {
//       this(new ULONG_PTR(0));
//    }
// 
//    public ULONG_PTRByReference(ULONG_PTR value)
//    {
//       super(Native.POINTER_SIZE);
//       setValue(value);
//    }
// 
//    public void setValue(ULONG_PTR value)
//    {
//       if (Native.POINTER_SIZE == 4) {
//          getPointer().setInt(0, value.intValue());
//       }
//       else {
//          getPointer().setLong(0, value.longValue());
//       }
//    }
// 
//    public ULONG_PTR getValue()
//    {
//       return new ULONG_PTR(Native.POINTER_SIZE == 4 ? getPointer().getInt(0) : getPointer().getLong(0));
//    }
// }
// 
// Path: src/main/java/com/zaxxer/nuprocess/windows/WindowsProcess.java
// static final class PipeBundle
// {
//    final OVERLAPPED overlapped;
//    final long ioCompletionKey;
//    final HANDLE pipeHandle;
//    ByteBuffer buffer;
//    boolean registered;
// 
//    PipeBundle(HANDLE pipeHandle, long ioCompletionKey)
//    {
//       this.pipeHandle = pipeHandle;
//       this.ioCompletionKey = ioCompletionKey;
// 
//       // The OVERLAPPED structure is required to make non-blocking ReadFile and WriteFile calls,
//       // but its state is never read from nor written to in Java, so we disable auto-sync so JNA
//       // doesn't waste time marshaling contents to/from native memory
//       overlapped = new OVERLAPPED();
//       overlapped.setAutoSynch(false);
//    }
// }


// Path: src/main/java/com/zaxxer/nuprocess/windows/ProcessCompletions.java
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.sun.jna.Native;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.zaxxer.nuprocess.internal.Constants;
import com.zaxxer.nuprocess.windows.NuWinNT.HANDLE;
import com.zaxxer.nuprocess.windows.NuWinNT.ULONG_PTR;
import com.zaxxer.nuprocess.windows.NuWinNT.ULONG_PTRByReference;
import com.zaxxer.nuprocess.windows.WindowsProcess.PipeBundle;

      try {
         wantsWrite.put(process);
         NuKernel32.PostQueuedCompletionStatus(ioCompletionPort, 0, new ULONG_PTR(0), null);
      }
      catch (InterruptedException e) {
         // ignore
      }
   }

   void registerProcess(final WindowsProcess process)
   {
      if (shutdown) {
         return;
      }

      try {
         pendingPool.put(process);
         NuKernel32.PostQueuedCompletionStatus(ioCompletionPort, 0, new ULONG_PTR(0), null);
      }
      catch (InterruptedException e) {
         // ignore
      }
   }

   private void queueWrite(final WindowsProcess process)
   {
      if (shutdown) {
         return;
      }

      final PipeBundle stdinPipe = process.getStdinPipe();