/** FILE bufferan.java **/

package BUFFER;

// Referenced classes of package BUFFER:
//            buffer, accex

/*
 * Gestione del buffer in assenza di politica (ANARCHICA)
 */

public class bufferan extends buffer
{

    public synchronized void put(String s)
        throws InterruptedException
    {
        accex accex1 = accput;    // nuovo oggetto assegnato al thread per memorizzare gli accessi
        accex1.next = new accex();
        accex1.acc1 = accessi++;  // QUI incremento accessi == gli EVENTI
        accput = accput.next;
        for(; liberi < s.length(); wait()); // controllo base: c'è spazio nel buffer??
        accex1.acc2 = accessi;
        notifyAll();
        super.put(s);  // --> vedi buffer.java (inserimento di un messaggio)
    }

    public synchronized String get()
        throws InterruptedException
    {
        accex accex1 = accget;    // nuovo oggetto assegnato al thread per memorizzare gli accessi
        accex1.next = new accex();
        accex1.acc1 = accessi++;    // QUI incremento accessi == gli EVENTI
        accget = accget.next;
        while(liberi == 200)  // controllo base: il buffer è vuoto??
            wait();

        accex1.acc2 = accessi;
        notifyAll();
        return super.get();   // --> vedi buffer.java  (cancellazione di un messaggio)
    }

    public bufferan()
    {
    }
}