Help for this page

Select Code to Download


  1. or download this
    my $head = 0;  # Can only be modified by the lone writer thread
    my $tail = 0;  # Can only be modified by the lone reader thread
    ...
        $head = ( $head + 1 ) % @buf;
        return 1;
    }
    
  2. or download this
    package Data::RingBuffer;
    
    ...
        $self->{head} = ( $self->{head} + 1 ) % @$buf;
        return 1;
    }