<commit_before>package hasher

import (
	"sync"
)

type Buffer struct {
	buf  []Chunk
	eof  chan struct{}
	mu   sync.RWMutex
	cond sync.Cond
}

func NewBuffer(chunked <-chan Chunk) *Buffer {
	b := &Buffer{eof: make(chan struct{})}
	b.cond.L = &b.mu
	go func() {
		for chunk := range chunked {
			b.mu.Lock()
			b.buf = append(b.buf, chunk)
			b.mu.Unlock()
			b.cond.Broadcast()
		}
		close(b.eof)
		b.mu.Lock()
		b.mu.Unlock()
		b.cond.Broadcast()
	}()
	return b
}

func (b *Buffer) isEof() bool {
	select {
	case <-b.eof:
		return true
	default:
		return false
	}<commit_msg>Wrong locker given to sync.Cond<commit_after>package hasher

import (
	"sync"
)

type Buffer struct {
	buf  []Chunk
	eof  chan struct{}
	mu   sync.RWMutex
	cond sync.Cond
}

func NewBuffer(chunked <-chan Chunk) *Buffer {
	b := &Buffer{eof: make(chan struct{})}
	b.cond.L = b.mu.RLocker()
	go func() {
		for chunk := range chunked {
			b.mu.Lock()
			b.buf = append(b.buf, chunk)
			b.mu.Unlock()
			b.cond.Broadcast()
		}
		close(b.eof)
		b.mu.Lock()
		b.mu.Unlock()
		b.cond.Broadcast()
	}()
	return b
}

func (b *Buffer) isEof() bool {
	select {
	case <-b.eof:
		return true
	default:
		return false
	}
{'fraction_non_alphanumeric': 0.16003386960203217, 'fraction_numerical': 0.0, 'mean_word_length': 2.9269102990033224, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2435128', 'n_tokens_mistral': 540, 'n_tokens_neox': 503, 'n_words': 120}