2 # Finite size ring buffer creation and access routines
4 # Copyright (c) - 1998 Dirk Koopman G1TLH
13 use vars qw($VERSION $BRANCH);
14 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
15 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0));
16 $main::build += $VERSION;
17 $main::branch += $BRANCH;
24 return bless [$size, 0, 0, 0, 0, []], (ref $pkg || $pkg);
31 $self->[5]->[$self->[2]++] = shift;
32 $self->[2] = 0 if $self->[2] >= $self->[0];
33 if ($self->[1] < $self->[0]) {
34 $self->[1] = ++$self->[1];
36 $self->[2] = $self->[2];
37 if ($self->[1] == $self->[0] && $self->[2] == $self->[3]) {
38 $self->[3] = $self->[2]+1;
39 $self->[3] = 0 if $self->[3] >= $self->[0];
46 return unless $self->[1];
49 if ($self->[4] != $self->[2]) {
50 $r = $self->[5]->[$self->[4]++];
51 $self->[4] = 0 if $self->[4] >= $self->[0];
59 $self->[4] = $self->[3];
74 while (my $r = $self->read) {