func (f *Future) WaitWithContext(ctx context.Context) (interface{}, error) {
	// If the future has been canceled, tell them
	if f.canceled {
		return nil, ErrFutureCanceled
	}

	// If we have a result channel, simply wait on it
	if f.result != nil {
		// If the result is empty, the channel has been closed
		if ent := f.wait(ctx); ent.Object != nil || ent.Error != nil {
			f.result = nil
			return ent.Object, ent.Error
		}
	}

	// No result channel; lock the cache and get the entry
	// contents
	f.fc.Lock()
	defer f.fc.Unlock()
	if f.ent.content == nil {
		// Hmm, probably shouldn't happen...
		return nil, ErrNotCached
	}

	return f.ent.content.Object, f.ent.content.Error
}
// WaitWithContext waits for the future to be completed and returns
// the desired result.  It accepts a context.Context to specify a
// context that may be used to cancel the wait.  Note that the future
// remains active, and a later call to Wait or WaitWithContext may be
// made.
WaitWithContext waits for the future to be completed and returns
the desired result.  It accepts a context.Context to specify a
context that may be used to cancel the wait.  Note that the future
remains active, and a later call to Wait or WaitWithContext may be
made.
// WaitWithContext waits for the future to be completed and returns // the desired result . It accepts a context . Context to specify a // context that may be used to cancel the wait . Note that the future // remains active and a later call to Wait or WaitWithContext may be // made .
func (f *Future) WaitWithContext(ctx context.Context) (interface{}, error) {
	if f.canceled {
		return nil, ErrFutureCanceled
	}
	if f.result != nil {
		if ent := f.wait(ctx); ent.Object != nil || ent.Error != nil {
			f.result = nil
			return ent.Object, ent.Error
		}
	}
	f.fc.Lock()
	defer f.fc.Unlock()
	if f.ent.content == nil {
		return nil, ErrNotCached
	}
	return f.ent.content.Object, f.ent.content.Error
}
func ( f * Future ) WaitWithContext ( ctx context . Context ) ( interface { } , error ) { if f . canceled { return nil , ErrFutureCanceled } if f . result != nil { if ent := f . wait ( ctx ) ; ent . Object != nil || ent . Error != nil { f . result = nil return ent . Object , ent . Error } } f . fc . Lock ( ) defer f . fc . Unlock ( ) if f . ent . content == nil { return nil , ErrNotCached } return f . ent . content . Object , f . ent . content . Error }
WaitWithContext waits for the future to be completed and returns
the desired result.
WaitWithContext waits for the future to be completed and returns the desired result .
// If the future has been canceled, tell them // If we have a result channel, simply wait on it // If the result is empty, the channel has been closed // No result channel; lock the cache and get the entry // contents // Hmm, probably shouldn't happen...