+/EE360P
distributed systems
git clone https://git.julia.blue/+/EE360P
cccc41d
master
1public class SingleQueue {// Single Producer Single Consumer 2int head =0 ;// slot for get 3int tail =0 ;// empty slot for put 4Object []items ; 5public SingleQueue (int size ) { 6head =0 ;tail =0 ; 7items =new Object [size ]; 8 } 9public void put (Object x ) { 10while (tail -head ==items .length ) {};//busywait 11items [tail %items .length ] =x ; 12tail ++; 13 } 14public Object get () { 15while (tail -head ==0 ) {};// busywait 16Object x =items [head %items .length ]; 17head ++; 18return x ; 19 } 20}