Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9405)

Issue 3775048: code review 3775048: sync: Proposal for condition variable support. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 3 months ago by niemeyer
Modified:
13 years, 2 months ago
Reviewers:
CC:
rsc, rog, r, golang-dev
Visibility:
Public.

Description

sync: condition variable support. This change introduces a new condition variable implementation which helps solving some well known synchronization problems in a simple way.

Patch Set 1 #

Patch Set 2 : code review 3775048: sync: Proposal for condition variable support. #

Patch Set 3 : code review 3775048: sync: Proposal for condition variable support. #

Patch Set 4 : code review 3775048: sync: Proposal for condition variable support. #

Patch Set 5 : code review 3775048: sync: Proposal for condition variable support. #

Patch Set 6 : code review 3775048: sync: Proposal for condition variable support. #

Patch Set 7 : code review 3775048: sync: Proposal for condition variable support. #

Patch Set 8 : code review 3775048: sync: Proposal for condition variable support. #

Patch Set 9 : code review 3775048: sync: Proposal for condition variable support. #

Total comments: 40

Patch Set 10 : code review 3775048: sync: Proposal for condition variable support. #

Patch Set 11 : code review 3775048: sync: Proposal for condition variable support. #

Patch Set 12 : code review 3775048: sync: Proposal for condition variable support. #

Patch Set 13 : diff -r f37c651d8774 https://go.googlecode.com/hg/ #

Patch Set 14 : diff -r f37c651d8774 https://go.googlecode.com/hg/ #

Total comments: 5

Patch Set 15 : diff -r 91202941cf4c https://go.googlecode.com/hg/ #

Total comments: 1

Patch Set 16 : diff -r 91202941cf4c https://go.googlecode.com/hg/ #

Patch Set 17 : diff -r 91202941cf4c https://go.googlecode.com/hg/ #

Patch Set 18 : diff -r 91202941cf4c https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+241 lines, -0 lines) Patch
M src/pkg/sync/Makefile View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -0 lines 0 comments Download
A src/pkg/sync/cond.go View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +89 lines, -0 lines 0 comments Download
A src/pkg/sync/cond_test.go View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +99 lines, -0 lines 0 comments Download
M src/pkg/sync/mutex.go View 1 2 3 4 5 6 7 8 9 10 1 chunk +6 lines, -0 lines 0 comments Download
M src/pkg/sync/rwmutex.go View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +11 lines, -0 lines 0 comments Download
M src/pkg/sync/rwmutex_test.go View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +35 lines, -0 lines 0 comments Download

Messages

Total messages: 36
niemeyer
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change.
13 years, 3 months ago (2011-01-05 02:43:22 UTC) #1
rsc
I'd prefer not to add this to package sync. In most of the cases where ...
13 years, 3 months ago (2011-01-05 18:07:34 UTC) #2
niemeyer
In the cases where simple channel communication is a better answer, we have channels, which ...
13 years, 3 months ago (2011-01-05 18:27:34 UTC) #3
rsc
> Simple real world example: > > iter.gotReply.Wait(func() bool { > iter.m.Lock() > if iter.err ...
13 years, 3 months ago (2011-01-05 19:34:30 UTC) #4
niemeyer
> I don't have any idea what this code does. It waits. ;-) > (Also ...
13 years, 3 months ago (2011-01-05 23:03:47 UTC) #5
rsc
The problem is that I don't know what problem you're trying to solve. You wrote: ...
13 years, 3 months ago (2011-01-06 00:09:24 UTC) #6
niemeyer
> They are undoubtedly a useful building block, but I don't > think that package ...
13 years, 3 months ago (2011-01-06 01:27:04 UTC) #7
niemeyer
Actually, disregard cond.RWait(rwmutex) please. We need a mutual exclusion either way to safely access internal ...
13 years, 3 months ago (2011-01-06 01:45:58 UTC) #8
niemeyer
Spoke too soon. Signal() and Broadcast() would need the internal mutex, so RWait() won't really ...
13 years, 3 months ago (2011-01-06 01:53:32 UTC) #9
rsc
Is there a reason not to make Wait and Signal direct methods of the locks? ...
13 years, 3 months ago (2011-01-06 03:29:45 UTC) #10
niemeyer
> Is there a reason not to make Wait and Signal > direct methods of ...
13 years, 3 months ago (2011-01-06 12:04:25 UTC) #11
niemeyer
FWIW, I can possibly reduce the amount of memory used for the structure considerably basing ...
13 years, 3 months ago (2011-01-06 13:20:03 UTC) #12
niemeyer
I've just uploaded a *much* simpler version based on semaphores and cas, and turning the ...
13 years, 3 months ago (2011-01-06 14:38:35 UTC) #13
rsc
That looks a lot better. I don't think you want the RWMutex to be embedded, ...
13 years, 3 months ago (2011-01-06 15:25:08 UTC) #14
niemeyer
> That looks a lot better. Thanks. > I don't think you want the RWMutex ...
13 years, 3 months ago (2011-01-06 17:16:20 UTC) #15
niemeyer
Refactored as discussed, races fixed, tests added. PTAL
13 years, 3 months ago (2011-01-06 21:16:40 UTC) #16
niemeyer
Last night I finally ported my in-development DB library to work with this new interface, ...
13 years, 3 months ago (2011-01-12 16:50:02 UTC) #17
rog
http://codereview.appspot.com/3775048/diff/34001/src/pkg/sync/cond.go File src/pkg/sync/cond.go (right): http://codereview.appspot.com/3775048/diff/34001/src/pkg/sync/cond.go#newcode11 src/pkg/sync/cond.go:11: M Locker just one thought: is it actually useful ...
13 years, 3 months ago (2011-01-12 17:26:58 UTC) #18
niemeyer
http://codereview.appspot.com/3775048/diff/34001/src/pkg/sync/cond.go File src/pkg/sync/cond.go (right): http://codereview.appspot.com/3775048/diff/34001/src/pkg/sync/cond.go#newcode11 src/pkg/sync/cond.go:11: M Locker > just one thought: is it actually ...
13 years, 3 months ago (2011-01-12 17:43:29 UTC) #19
rog
http://codereview.appspot.com/3775048/diff/34001/src/pkg/sync/cond.go File src/pkg/sync/cond.go (right): http://codereview.appspot.com/3775048/diff/34001/src/pkg/sync/cond.go#newcode11 src/pkg/sync/cond.go:11: M Locker On 2011/01/12 17:43:29, niemeyer wrote: > > ...
13 years, 3 months ago (2011-01-12 18:03:11 UTC) #20
rsc
A bunch of comments, mainly about comments. The code is very nice and clean. The ...
13 years, 3 months ago (2011-01-12 18:26:33 UTC) #21
rsc
> good point. an alternative might be to make M private and > provide a ...
13 years, 3 months ago (2011-01-12 18:28:04 UTC) #22
niemeyer
> A bunch of comments, mainly about comments. > The code is very nice and ...
13 years, 3 months ago (2011-01-12 19:22:27 UTC) #23
niemeyer
Updated tests after recent changes to non-blocking channel sends.
13 years, 2 months ago (2011-02-01 09:47:25 UTC) #24
niemeyer
Patch wasn't applying cleanly anymore. Had to download the patch, clean it up, and push ...
13 years, 2 months ago (2011-02-04 00:01:14 UTC) #25
rsc
LGTM I think this turned out nice. Adding r to reviewer list.
13 years, 2 months ago (2011-02-11 21:30:31 UTC) #26
r
http://codereview.appspot.com/3775048/diff/62001/src/pkg/sync/cond.go File src/pkg/sync/cond.go (right): http://codereview.appspot.com/3775048/diff/62001/src/pkg/sync/cond.go#newcode12 src/pkg/sync/cond.go:12: // Each Cond has an associated locker M (often ...
13 years, 2 months ago (2011-02-15 23:42:01 UTC) #27
rsc
> http://codereview.appspot.com/3775048/diff/62001/src/pkg/sync/cond.go#newcode70 > src/pkg/sync/cond.go:70: func (c *Cond) Signal() int { > why not a boolean? ...
13 years, 2 months ago (2011-02-16 04:53:40 UTC) #28
r
On Tue, Feb 15, 2011 at 8:53 PM, Russ Cox <rsc@golang.org> wrote: >> http://codereview.appspot.com/3775048/diff/62001/src/pkg/sync/cond.go#newcode70 >> ...
13 years, 2 months ago (2011-02-16 07:20:55 UTC) #29
niemeyer
All sorted. PTAL
13 years, 2 months ago (2011-02-16 07:32:57 UTC) #30
r
this seems good to me modulo two comment tweaks. leaving for rsc. http://codereview.appspot.com/3775048/diff/70001/src/pkg/sync/cond.go File src/pkg/sync/cond.go ...
13 years, 2 months ago (2011-02-16 16:19:24 UTC) #31
rsc
> I don't think that's compelling. I need to check against 0 or 1 to ...
13 years, 2 months ago (2011-02-16 16:22:49 UTC) #32
r
getting rid of it is ok too. it's in your court. i agree this turned ...
13 years, 2 months ago (2011-02-16 16:24:08 UTC) #33
rsc
gustavo, if you agree, go ahead and remove the return values.
13 years, 2 months ago (2011-02-16 16:34:29 UTC) #34
niemeyer
> gustavo, if you agree, go ahead and remove the return values. I don't have ...
13 years, 2 months ago (2011-02-16 17:21:53 UTC) #35
rsc
13 years, 2 months ago (2011-02-16 19:11:12 UTC) #36
*** Submitted as d3bc87b547a4 ***

sync: add Cond

R=rsc, rog, r
CC=golang-dev
http://codereview.appspot.com/3775048

Committer: Russ Cox <rsc@golang.org>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b