<commit_before>package classic

import (
	"sync"
)

// BlockingSemaphore ...
// https://en.wikipedia.org/wiki/Semaphore_(programming)#Operation_names
type BlockingSemaphore interface {
	// P ...
	P(n int)
	// V ...
	V(n int)
}

// NewBlockingSemaphore constructs a new BlockingSemaphore with the given number of places.
func NewBlockingSemaphore(size int) BlockingSemaphore {
	return make(semaphore, size)
}

func (sem semaphore) P(n int) {
	for i := 0; i < n; i++ {
		sem <- struct{}{}
	}
}

func (sem semaphore) V(n int) {
	for i := 0; i < n; i++ {
		<-sem
	}
}

// ProcessSemaphore ...
// https://en.wikipedia.org/wiki/Semaphore_(programming)#Semantics_and_implementation
type ProcessSemaphore interface {
	Signal()
	Wait(n int)
}

// NewProcessSemaphore constructs a new ProcessSemaphore with the given number of places.
func NewProcessSemaphore(size int) ProcessSemaphore {
	return make(semaphore, size)
}

// logic is inverted
func (sem semaphore) Signal() {
	sem.P(1)
}

// logic is inverted
func (sem semaphore) Wait(n int) {
	sem.V(n)
}

// BinarySemaphore represents the classic binary semaphore with mutex-like interface.
type BinarySemaphore interface {
	sync.Locker
}

// NewBinarySemaphore constructs a new BinarySemaphore with one place.
func NewBinarySemaphore() BinarySemaphore {
	return make(semaphore, 1)
}

func (sem semaphore) Lock() {
	sem.P(1)
}

func (sem semaphore) Unlock() {<commit_msg>restore ProcessSemaphore logic (Wait, Signal)<commit_after>package classic

import (
	"sync"
)

// BlockingSemaphore ...
// https://en.wikipedia.org/wiki/Semaphore_(programming)#Operation_names
type BlockingSemaphore interface {
	// P ...
	P(n int)
	// V ...
	V(n int)
}

// NewBlockingSemaphore constructs a new BlockingSemaphore with the given number of places.
func NewBlockingSemaphore(size int) BlockingSemaphore {
	return make(semaphore, size)
}

func (sem semaphore) P(n int) {
	for i := 0; i < n; i++ {
		sem <- struct{}{}
	}
}

func (sem semaphore) V(n int) {
	for i := 0; i < n; i++ {
		<-sem
	}
}

// ProcessSemaphore ...
// https://en.wikipedia.org/wiki/Semaphore_(programming)#Semantics_and_implementation
type ProcessSemaphore interface {
	Signal()
	Wait(n int)
}

// NewProcessSemaphore constructs a new ProcessSemaphore with the given number of places.
func NewProcessSemaphore(size int) ProcessSemaphore {
	sem := make(semaphore, size)
	sem.P(size)
	return sem
}

func (sem semaphore) Signal() {
	sem.V(1)
}

func (sem semaphore) Wait(n int) {
	sem.P(n)
}

// BinarySemaphore represents the classic binary semaphore with mutex-like interface.
type BinarySemaphore interface {
	sync.Locker
}

// NewBinarySemaphore constructs a new BinarySemaphore with one place.
func NewBinarySemaphore() BinarySemaphore {
	return make(semaphore, 1)
}

func (sem semaphore) Lock() {
	sem.P(1)
}

func (sem semaphore) Unlock() {
{'fraction_non_alphanumeric': 0.12390003519887363, 'fraction_numerical': 0.0035198873636043647, 'mean_word_length': 4.075, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '464122', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1018, 'n_words': 275}