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;
31 return bless [$size+1, 0, 0, 0, 0, []], (ref $pkg || $pkg);
38 $self->[5]->[$self->[2]++] = shift;
39 $self->[2] = 0 if $self->[2] >= $self->[0];
40 $self->[1]++ if $self->[1] < $self->[0];
41 if ($self->[1] == $self->[0] && $self->[2] == $self->[3]) {
42 $self->[3] = $self->[2]+1;
43 $self->[3] = 0 if $self->[3] >= $self->[0];
50 return unless $self->[1];
53 if ($self->[4] != $self->[2]) {
54 $r = $self->[5]->[$self->[4]++];
55 $self->[4] = 0 if $self->[4] >= $self->[0];
63 $self->[4] = $self->[3];
78 while (my $r = $self->read) {