Skip to content

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

@masrur-mahmood-cdx

Description

@masrur-mahmood-cdx

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions