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

Fix access to map from multiple goroutines #258

Merged
merged 3 commits into from
Feb 16, 2019

Conversation

Pliner
Copy link
Contributor

@Pliner Pliner commented Feb 16, 2019

https://golang.org/ref/mem#tmp_10

Another incorrect idiom is busy waiting for a value, as in:

var a string
var done bool

func setup() {
	a = "hello, world"
	done = true
}

func main() {
	go setup()
	for !done {
	}
	print(a)
}

As before, there is no guarantee that, in main, observing the write to done implies observing the write to a, so this program could print an empty string too. Worse, there is no guarantee that the write to done will ever be observed by main, since there are no synchronization events between the two threads. The loop in main is not guaranteed to finish.

@Pliner Pliner added the WIP Work in progress label Feb 16, 2019
@Pliner Pliner changed the title Fix access to lazyTriggerIDs Fix access to map from multiple goroutines Feb 16, 2019
@borovskyav borovskyav requested review from borovskyav and titusjaka and removed request for titusjaka February 16, 2019 13:06
@coveralls
Copy link

coveralls commented Feb 16, 2019

Coverage Status

Coverage remained the same at 83.12% when pulling 1b618d9 on fix-access-to-map-from-multiple-goroutines into 80d479a on develop.

@borovskyav borovskyav force-pushed the fix-access-to-map-from-multiple-goroutines branch from 54d578b to 1b618d9 Compare February 16, 2019 14:16
@borovskyav borovskyav merged commit 3526b32 into develop Feb 16, 2019
@borovskyav borovskyav deleted the fix-access-to-map-from-multiple-goroutines branch February 16, 2019 17:02
@Pliner Pliner removed the WIP Work in progress label Feb 16, 2019
@Pliner Pliner mentioned this pull request Feb 17, 2019
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