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

Question: Does status need to be mutex protected? #2

Open
masrur-mahmood-cdx opened this issue May 26, 2023 · 0 comments
Open

Question: Does status need to be mutex protected? #2

masrur-mahmood-cdx opened this issue May 26, 2023 · 0 comments

Comments

@masrur-mahmood-cdx
Copy link

Hello,

I'm very impressed with the work you did on this library. Very neat indeed. I had a question for you... in your implementation of the Promise struct, is there a reason why status doesn't need to be mutex protected?

type Promise struct {
	// Fn represent the underlaying promised function
	fn func(*Promise, ...interface{})

	// Args represents the arguments that needs to be passed when the promise is invoked
	args []interface{}

	// Not Started: 0
	// Pending: 1
	// Finished: 2
	status byte                    // <---- does this status variable need to be protected by a mutex or rwmutex?
	wg     sync.WaitGroup

	then ThenHandler
	// Result
	result interface{}

	// Error
	err error

	batch bool
}
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

No branches or pull requests

1 participant