2 # Finite size ring buffer creation and access routines
4 # Copyright (c) - 1998 Dirk Koopman G1TLH
25 return bless [$size+1, 0, 0, 0, 0, []], (ref $pkg || $pkg);
32 $self->[5]->[$self->[2]++] = shift;
33 $self->[2] = 0 if $self->[2] >= $self->[0];
34 $self->[1]++ if $self->[1] < $self->[0];
35 if ($self->[1] == $self->[0] && $self->[2] == $self->[3]) {
36 $self->[3] = $self->[2]+1;
37 $self->[3] = 0 if $self->[3] >= $self->[0];
44 return unless $self->[1];
47 if ($self->[4] != $self->[2]) {
48 $r = $self->[5]->[$self->[4]++];
49 $self->[4] = 0 if $self->[4] >= $self->[0];
57 $self->[4] = $self->[3];
72 while (my $r = $self->read) {