Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make async runner wait for async operations
- Loading branch information
Showing
11 changed files
with
483 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
google-cloud-spanner/src/main/java/com/google/cloud/spanner/ForwardingAsyncResultSet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.spanner; | ||
|
||
import com.google.api.core.ApiFuture; | ||
import com.google.common.base.Function; | ||
import com.google.common.base.Preconditions; | ||
import com.google.common.collect.ImmutableList; | ||
import java.util.concurrent.Executor; | ||
|
||
/** Forwarding implementation of {@link AsyncResultSet} that forwards all calls to a delegate. */ | ||
public class ForwardingAsyncResultSet extends ForwardingResultSet implements AsyncResultSet { | ||
final AsyncResultSet delegate; | ||
|
||
public ForwardingAsyncResultSet(AsyncResultSet delegate) { | ||
super(Preconditions.checkNotNull(delegate)); | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public CursorState tryNext() throws SpannerException { | ||
return delegate.tryNext(); | ||
} | ||
|
||
@Override | ||
public void setCallback(Executor exec, ReadyCallback cb) { | ||
delegate.setCallback(exec, cb); | ||
; | ||
} | ||
|
||
@Override | ||
public void cancel() { | ||
delegate.cancel(); | ||
} | ||
|
||
@Override | ||
public void resume() { | ||
delegate.resume(); | ||
} | ||
|
||
@Override | ||
public <T> ApiFuture<ImmutableList<T>> toListAsync( | ||
Function<StructReader, T> transformer, Executor executor) { | ||
return delegate.toListAsync(transformer, executor); | ||
} | ||
|
||
@Override | ||
public <T> ImmutableList<T> toList(Function<StructReader, T> transformer) | ||
throws SpannerException { | ||
return delegate.toList(transformer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.