<commit_before>package main

type thing interface {
	Id() identifier
	Name() string
	Brief() string
	Long() string
}

type actualThing struct {
	id    identifier
	name  string
	brief string
	long  string
}

func (t actualThing) Id() identifier {
	return t.id
}
func (t actualThing) Name() string {
	return t.name
}
func (t actualThing) Brief() string {
	return t.brief
}
func (t actualThing) Long() string {
	return t.long
}

func getThingGetter(id identifier, getGetter chan struct {
	id       identifier
	response chan chan thing
},) chan thing {
	response := make(chan chan thing)
	getGetter <- struct {
		id       identifier
		response chan chan thing
	}{id, response}
	return <-response
}

func getThing(id identifier, getGetter chan struct {
	id       identifier
	response chan chan thing
},) thing {
	getter := getThingGetter(id, getGetter)
	return <-getter
}

func getThingSetter(id identifier, getSetter chan struct {
	id       identifier
	response chan chan chan thing
},) chan chan thing {
	response := make(chan chan chan thing)
	getSetter <- struct {
		id       identifier
		response chan chan chan thing
	}{id, response}
	return <-response
}

//func addThing

func initThingManager() (
	chan struct {
		id       identifier
		response chan chan thing
	},
	chan struct {
		id       identifier
		response chan chan chan thing
	},
	chan thing,
	chan identifier) {

	getGetter := make(chan struct {
		id       identifier
		response chan chan thing
	})
	getSetter := make(chan struct {
		id       identifier
		response chan chan chan thing
	})
	add := make(chan thing)
	del := make(chan identifier)
	go func() {
		things := make(map[identifier]struct {
			getter chan thing
			setter chan chan thing
			closer chan bool
		})
		for {
			select {
			case a := <-add:
				getter := make(chan thing)
				setter := make(chan chan thing)
				closer := make(chan bool)
				getter <- a
				go func() {
					it := <-getter
					itc := make(chan thing)
					for {
						select {
						case setter <- itc:
							it = <-itc
						case getter <- it:
						case <-closer:
							close(getter)
							close(setter)
							return
						}
					}
				}()
				things[a.Id()] = struct {
					getter chan thing
					setter chan chan thing
					closer chan bool
				}{getter, setter, closer}
			case d := <-del:
				things[d].closer <- true
				delete(things, d)
			case g := <-getGetter:
				g.response <- things[g.id].getter<commit_msg>changed data.go setter chan to also return the current thing instance<commit_after>package main

type thing interface {
	Id() identifier
	Name() string
	Brief() string
	Long() string
}

type actualThing struct {
	id    identifier
	name  string
	brief string
	long  string
}

func (t actualThing) Id() identifier {
	return t.id
}
func (t actualThing) Name() string {
	return t.name
}
func (t actualThing) Brief() string {
	return t.brief
}
func (t actualThing) Long() string {
	return t.long
}

func getThingGetter(id identifier, getGetter chan struct {
	id       identifier
	response chan chan thing
},) chan thing {
	response := make(chan chan thing)
	getGetter <- struct {
		id       identifier
		response chan chan thing
	}{id, response}
	return <-response
}

func getThing(id identifier, getGetter chan struct {
	id       identifier
	response chan chan thing
},) thing {
	getter := getThingGetter(id, getGetter)
	return <-getter
}

func getThingSetter(id identifier, getSetter chan struct {
	id       identifier
	response chan chan struct {
		it  thing
		set chan thing
	}
},) chan struct {
	it  thing
	set chan thing
} {
	response := make(chan chan struct {
		it  thing
		set chan thing
	})
	getSetter <- struct {
		id       identifier
		response chan chan struct {
			it  thing
			set chan thing
		}
	}{id, response}
	return <-response
}

//func addThing

func initThingManager() (
	chan struct {
		id       identifier
		response chan chan thing
	},
	chan struct {
		id       identifier
		response chan chan struct {
			it  thing
		        set chan thing
		}
	},
	chan thing,
	chan identifier) {

	getGetter := make(chan struct {
		id       identifier
		response chan chan thing
	})
	getSetter := make(chan struct {
		id       identifier
		response chan chan struct {
			it  thing
			set chan thing
		}
	})
	add := make(chan thing)
	del := make(chan identifier)
	go func() {
		things := make(map[identifier]struct {
			getter chan thing
			setter chan struct {
				it  thing
				set chan thing
			}
			closer chan bool
		})
		for {
			select {
			case a := <-add:
				getter := make(chan thing)
				setter := make(chan struct {
					it  thing
					set chan thing
				})
				closer := make(chan bool)
				getter <- a
				go func() {
					it := <-getter
					itc := make(chan thing)
					for {
						select {
						case setter <- struct {
							it  thing
							set chan thing
						}{it: it, set: itc}:
							it = <-itc
						case getter <- it:
						case <-closer:
							close(getter)
							close(setter)
							return
						}
					}
				}()
				things[a.Id()] = struct {
					getter chan thing
					setter chan struct {
						it  thing
						set chan thing
					}
					closer chan bool
				}{getter, setter, closer}
			case d := <-del:
				things[d].closer <- true
				delete(things, d)
			case g := <-getGetter:
				g.response <- things[g.id].getter
{'fraction_non_alphanumeric': 0.09458948164964057, 'fraction_numerical': 0.0, 'mean_word_length': 2.499007279947055, 'pattern_counts': {'":': 0, '<': 35, '<?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': '25380', 'n_tokens_mistral': 2154, 'n_tokens_neox': 1690, 'n_words': 582}