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

Make batcher ordered #111

Merged
merged 1 commit into from
Aug 24, 2015
Merged

Conversation

brianshannan-wf
Copy link
Collaborator

We now have a use case where we need to support ordering such that if any thread executes
batcher.Put(item1); batcher.Put(item2);, a single consumer thread will be guaranteed to see item1 before item2. As go's sync package is awesome and doesn't offer a TryLock function, I implemented a basic mutex using a channel of size 1 to support this, which I believe is correct. If you don't think this is efficient enough, it could be implemented using atomics. I think I avoided potential deadlocks while doing this, but it definitely wouldn't hurt to take a close look.

@tylertreat-wf @stevenosborne-wf @tylerrinnan-wf @dustinhiatt-wf @alexandercampbell-wf

@tylertreat-wf
Copy link
Contributor

+1

return true
default:
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

@dustinhiatt-wf
Copy link
Contributor

+1

// 2) A Put or Flush temporarily has the lock.
// In either case, trying to read something off the batch chan,
// and going back to trying to get a lock if unsuccessful
// works.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some typos in this comment.

"trying to read something" -> "try to read something"
"going back to trying"     -> "go back to trying"
"if unsuccessful works"    -> "if unsuccessful"

@tylerrinnan-wf
Copy link

+1

@alexandercampbell-wk
Copy link
Contributor

Minor comments. +1 otherwise.

tylertreat-wf added a commit that referenced this pull request Aug 24, 2015
@tylertreat-wf tylertreat-wf merged commit e98f2a3 into Workiva:master Aug 24, 2015
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.

5 participants