This file contains hidden or 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
package actors | |
import com.google.common.util.concurrent.ListenableFuture | |
import com.google.common.util.concurrent.SettableFuture | |
import com.google.common.util.concurrent.MoreExecutors | |
import java.util.concurrent.Executors | |
import java.util.ArrayList | |
import java.util.concurrent.LinkedBlockingQueue | |
import com.google.common.util.concurrent.ListeningExecutorService | |
import java.util.concurrent.ThreadFactory |
This file contains hidden or 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
import com.google.common.util.concurrent.ListeningExecutorService | |
import com.google.common.util.concurrent.MoreExecutors | |
import java.util.concurrent.Executors | |
import com.google.common.util.concurrent.ListenableFuture | |
import com.google.common.util.concurrent.Futures | |
import com.google.common.util.concurrent.FutureCallback | |
import com.google.common.util.concurrent.SettableFuture | |
import java.util.ArrayList | |
object KFutures { |
This file contains hidden or 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
/* | |
* Copyright 2013 Basho Technologies Inc | |
* | |
* 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 |
This file contains hidden or 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
/* | |
* Copyright 2013 Basho Technologies Inc | |
* | |
* 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 |
This file contains hidden or 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
public class ChainingExample { | |
private final Executor mainPool; | |
private final Executor ioPool; | |
public ChainingExample(Executor mainPool, Executor ioPool) { | |
this.mainPool = mainPool; | |
this.ioPool = ioPool; | |
} |
This file contains hidden or 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
public class FunctionComposerExample { | |
private final Executor mainPool; | |
private final Executor ioPool; | |
public FunctionComposerExample(Executor mainPool, Executor ioPool) { | |
this.mainPool = mainPool; | |
this.ioPool = ioPool; | |
} | |
This file contains hidden or 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
ListenableFuture<RowKey> rowKeyFuture = indexService.lookUp(query); | |
AsyncFunction<RowKey, QueryResult> queryFunction = | |
new AsyncFunction<RowKey, QueryResult>() { | |
public ListenableFuture<QueryResult> apply(RowKey rowKey) { | |
return dataService.read(rowKey); | |
} | |
}; | |
ListenableFuture<QueryResult> queryFuture = transform(rowKeyFuture, queryFunction); |
This file contains hidden or 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
package org.robotninjas.util; | |
import com.google.common.base.Function; | |
import com.google.common.util.concurrent.*; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.Executor; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; |
This file contains hidden or 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
package org.robotninjas.util; | |
import com.google.common.base.Optional; | |
import com.google.common.util.concurrent.*; | |
import java.util.concurrent.Callable; | |
import java.util.concurrent.Executor; | |
import java.util.concurrent.TimeUnit; | |
public class AsyncCommand<V> { |
This file contains hidden or 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
package org.robotninjas.util; | |
import com.google.common.util.concurrent.AbstractFuture; | |
import com.google.common.util.concurrent.TimeLimiter; | |
import java.util.concurrent.Callable; | |
import java.util.concurrent.RunnableFuture; | |
import java.util.concurrent.TimeUnit; | |
public class TimeLimitedFutureTask<V> extends AbstractFuture<V> implements RunnableFuture<V> { |