Skip to content

Commit

Permalink
Code review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
oxtoacart committed Apr 20, 2016
1 parent 3e65590 commit 780f8a6
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/github.com/getlantern/eventual/eventual.go
Expand Up @@ -103,14 +103,12 @@ func (v *value) Cancel() {

func (v *value) Get(timeout time.Duration) (ret interface{}, valid bool) {
state := v.getState()
set := state != nil && state.set
canceled := state != nil && state.canceled

// First check for existing value using atomic operations (for speed)
if set {
if state.set {
// Value found, use it
return state.val, true
} else if canceled {
} else if state.canceled {
// Value was canceled, return false
return nil, false
}
Expand All @@ -123,14 +121,12 @@ func (v *value) Get(timeout time.Duration) (ret interface{}, valid bool) {
// If we didn't find an existing value, try again but this time using locking
v.mutex.Lock()
state = v.getState()
set = state != nil && state.set
canceled = state != nil && state.canceled

if set {
if state.set {
// Value found, use it
v.mutex.Unlock()
return state.val, true
} else if canceled {
} else if state.canceled {
// Value was canceled, return false
v.mutex.Unlock()
return nil, false
Expand Down

0 comments on commit 780f8a6

Please sign in to comment.