Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leave channel construction and goroutining to callers #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Leave channel construction and goroutining to callers #1

wants to merge 1 commit into from

Conversation

larsmans
Copy link

Just an idea: what if Entries.Keys and friends would not return a channel, but take one as an argument? That allows the caller to set the buffering, so a cact-like tool can perform reading and writing of corpora in parallel. (Untested proof of concept attached.)

Allows control over buffering to the caller, at the expense
of some boilerplate code.
@danieldk
Copy link
Member

danieldk commented Apr 7, 2013

I think that's indeed an improvement. Perhaps an even better solution would be pass a function to Keys et al. Then a caller could implement whatever behaviour it wishes. E.g. a closure could feed the values to a channel. But it would give the caller the option to use concurrency or not.

@danieldk
Copy link
Member

danieldk commented Apr 7, 2013

@pebbe
Copy link
Member

pebbe commented Apr 7, 2013

It has to be an unbuffered channel, or Break won't work. And you don't need a buffered channel to process its output in parallel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants