Serialio
Class SerByteQueue

java.lang.Object
  extended by Serialio.SerByteQueue

public class SerByteQueue
extends java.lang.Object

Implements a High-performance Byte FIFO using a ringbuffer.

  • Copyright (c) 1999-2004 Serialio.com, All Rights Reserved.

    creation 20 Apr 1999


    Constructor Summary
    SerByteQueue(int queueSize)
               
     
    Method Summary
     int available()
              Get number of bytes in the queue
     void clear()
              Clear the byte queue.
     byte get()
              Get byte from queue Note: will block if queue is empty
     void get(byte[] buf, int off, int cnt)
              Get bytes from queue and store into buffer Note: will block if insufficient bytes in queue.
     int getID()
              Get the Queue ID
     boolean isEmpty()
              Get empty state of queue
     boolean isFull()
              Get full state of queue
     void put(byte value)
              Put byte into queue Note: will block if queue is full
     void setID(int id)
              Set the Queue ID
     int size()
              Get size of queue.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    SerByteQueue

    public SerByteQueue(int queueSize)
    Method Detail

    get

    public void get(byte[] buf,
                    int off,
                    int cnt)
             throws java.lang.InterruptedException
    Get bytes from queue and store into buffer Note: will block if insufficient bytes in queue.

    Parameters:
    buf - The buffer to store the data
    off - The buffer offset to store the data
    cnt - The number of bytes to store in the
    Throws:
    java.lang.InterruptedException

    get

    public byte get()
             throws java.lang.InterruptedException
    Get byte from queue Note: will block if queue is empty

    Throws:
    java.lang.InterruptedException

    put

    public void put(byte value)
             throws java.lang.InterruptedException
    Put byte into queue Note: will block if queue is full

    Throws:
    java.lang.InterruptedException

    isEmpty

    public boolean isEmpty()
    Get empty state of queue

    Returns:
    true if queue is empty, otherwise false.

    isFull

    public boolean isFull()
    Get full state of queue

    Returns:
    true if queue is full, otherwise false.

    available

    public int available()
    Get number of bytes in the queue

    Returns:
    number of bytes available in the queue

    size

    public int size()
    Get size of queue.


    clear

    public void clear()
    Clear the byte queue.


    setID

    public void setID(int id)
    Set the Queue ID


    getID

    public int getID()
    Get the Queue ID