TWiki . Doc . PacketBenchExample

package bench;

let Packet NoPacket = new Packet();
let int DataSize = 4;

enum PacketKind { Device, Work }
enum PacketId { Idle, Worker, HandlerA, HandlerB, DeviceA, DeviceB }

class Packet {
      // Variables from spec
   private Packet link = NoPacket;   // pointer to the next Packet
   private PacketId id = Idle;        // task or device that sent the packet
   private PacketKind kind = Device; // part of the message
   private byte a1 = 0;                // part of the message
   private byte[] a2 = new byte[DataSize];


   Packet addTo(Packet queue) {
      Packet next, peek;
      link = NoPacket;
      if (queue == NoPacket) return this;
      next = queue;
      while ((peek = next.link) != NoPacket)
         next = peek;
      next.link = this;
      return queue;
   }

   Packet getLink() = link;

   void setLink(Packet p) = 
      link = p;

   PacketId getId() = id;

   void setId(PacketId i) = 
      id = i;

   PacketKind getKind() = kind;

   byte getA1() = a1;

   void setA1(byte a) = 
      a1 = a;

   byte[] getA2() = a2;
}
-- DuncanLissett - 02 Sep 2003

----- Revision r1.1 - 02 Sep 2003 - 20:26 GMT - DuncanLissett
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.