func (f *futureKey) Get() (Key, error) { f.o.Do(func() { var value *C.uint8_t var length C.int f.BlockUntilReady() if err := C.fdb_future_get_key(f.ptr, &value, &length); err != 0 { f.e = Error{int(err)} } else { f.k = C.GoBytes(unsafe.Pointer(value), length) } C.fdb_future_release_memory(f.ptr) }) return f.k, f.e }
// GetWithError returns a database key or an error if the asynchronous operation // associated with this future did not successfully complete. The current // goroutine will be blocked until the future is ready. func (f FutureKey) GetWithError() (Key, error) { if f.k != nil { return f.k, nil } var value *C.uint8_t var length C.int fdb_future_block_until_ready(f.ptr) if err := C.fdb_future_get_key(f.ptr, &value, &length); err != 0 { if err == 2017 { return f.k, nil } else { return nil, Error(err) } } f.k = C.GoBytes(unsafe.Pointer(value), length) C.fdb_future_release_memory(f.ptr) return f.k, nil }