future Questions

1

Solved

I'm using (def f (future (while (not (Thread/interrupted)) (function-to-run)))) (Thread/sleep 100) (future-cancel f) to cancel my code after a specified amount of time (100ms). The probl...
Shamikashamma asked 9/3, 2017 at 16:22

1

Solved

I'm using the future library and I have a future which implements Future<T, E>. I'd like to map this future with a function FnOnce(T) -> D where D: From<E>. Now when I want to wait()...
Burdick asked 27/2, 2017 at 15:5

1

Solved

Following example code I'm injecting a biconsumer which sleeps for 100 millis as a completion action of a set of completable future. I've used whenCompleteAsync method by giving a separate executor...
Kibe asked 21/2, 2017 at 16:38

1

Solved

I'm using Spring 4.2.3 AsyncRestTemplate.exchange() to call some API that will take several seconds, and i'm expecting that listenableFuture.get(1, TimeUnit.SECONDS) will block for 1 second and the...
Moraine asked 16/2, 2017 at 7:23

4

Solved

I have a Future[T] and I want to map the result, on both success and failure. Eg, something like val future = ... // Future[T] val mapped = future.mapAll { case Success(a) => "OK" case Fail...
He asked 13/4, 2014 at 14:3

1

Solved

I have built an akka graph that defines a flow. My objective is to reformat my future response and save it to a file. The flow can be outlined bellow: val g = RunnableGraph.fromGraph(GraphDSL.crea...
Mcmullen asked 6/2, 2017 at 3:24

1

Solved

I read the tokio documentation and I wonder what is the best approach for encapsulating costly synchronous I/O in a future. With the reactor framework, we get the advantage of a green threading mo...
Hydrogenous asked 30/1, 2017 at 9:7

3

Solved

Hey I got a quick question about Java Futures. I broke down the problem to this snippet: ExecutorService service = Executors.newCachedThreadPool(); try { System.out.println(service.submit(new F...
Sherasherar asked 19/1, 2017 at 15:35

7

Solved

I've been working with the Scala Akka library and have come across a bit of a problem. As the title says, I need to convert Map[A, Future[B]] to Future[Map[A,B]]. I know that one can use Future.seq...
Fixer asked 4/7, 2013 at 23:16

1

Solved

A pointer to a data structure is shared with multiple threads via std::promise and std::shared_future. From the book 'C++ concurrency in action' by Anthony Williams (pg. 85-86), it seems that data ...
Diploma asked 29/12, 2016 at 0:42

2

Solved

#include <iostream> #include <string> #include <thread> #include <future> int main() { auto pms = std::promise<std::string>(); auto ftr = pms.get_future(); std::...
Tirado asked 16/12, 2016 at 14:34

5

I need to combine two Future[List] into one and I came up with the following solution: def mergeFutureLists[X]( fl1: Future[List[X]], fl2: Future[List[X]] ): Future[List[X]] = { val lf = List( ...
Gammon asked 18/12, 2015 at 23:22

6

Solved

I would like to upgrade my MFC production code to use the std::shared_ptr smart pointer when calling other windows or threads. Such calls are SendMessage, PostMessage and PostThreadMessage which pa...
Harned asked 4/9, 2014 at 13:51

4

Solved

I want to write an asynchronous method that returns a CompletableFuture. The only purpose of the future is to track when the method is complete, not its result. Would it be better to return Complet...
Tow asked 11/12, 2015 at 22:10

1

Solved

I am new to scala.In Future, I saw it used in two different way i.e Future and future. Example: val sayHello = Future { Thread.sleep(1000) "hello" } Similarly, val sayHello = future { Thre...
Radiolarian asked 16/11, 2016 at 10:35

1

Solved

I have a problem when using CompletableFuture in java. I have 2 select requests those are filled when receiving responses from server. In the connection thread (THREAD-1) (use reactor), I use: if...
Corri asked 3/11, 2016 at 3:40

1

Solved

I am studying futures in my concurrent programming class. My professor has stated this in her slides: "Valid" futures are future objects associated to a  shared state, and are constructed by calli...
Korikorie asked 31/10, 2016 at 14:19

3

Solved

As I know, Future is read-only and Promise is write-once data structure. We need a Promise to complete a Future For example, object Lie extends Throwable val lie = Future { throw Lie } val ...
Inamorato asked 30/10, 2016 at 17:26

2

Solved

I'm reading Scala 2.11.8 documentation of andThen function in the scala.concurrent.Future module and it says the following: def andThen[U](pf: PartialFunction[Try[T], U]) (implicit executor: Exec...
Farahfarand asked 18/10, 2016 at 17:49

3

Experimenting with concurrent execution I was wondering how to actually test it. The execution flow is of a side-effect nature and futures are created to wrap independent executions/processing. Be...
Reluctivity asked 6/8, 2014 at 19:48

4

Solved

Java Future has cancel method, which can interrupt the thread, which runs the Future task. For example, if I wrap an interruptible blocking call in a Java Future I can interrupt it later. Scala Fu...
Customer asked 15/4, 2013 at 7:29

2

In Java 8 there are two ways of starting asynchronous computations - CompletableFuture and ForkJoinTask. They both seem fairly similar - the inner classes of CompletableFuture even extend ForkJoinT...
Sketch asked 26/11, 2015 at 17:43

2

I have a list of string ids representing DB records. I'd like to load them from the DB asynchronously, then upload each record to a remote server asynchronously, then when all are done uploading, m...
Empire asked 1/3, 2013 at 9:18

3

Solved

ExecutorService pool=Executors.newFixedThreadPool(7); List<Future<Hotel>> future=new ArrayList<Future<Hotel>>(); List<Callable<Hotel>> callList = new ArrayLis...
Gribble asked 13/8, 2013 at 6:46

3

Solved

I use Finagle as a web server which I want to return Scala-Futures from my application logic. How to convert scala.concurrent.Future to com.twitter.util.Future, in a non-blocking way of course?
Alnico asked 19/5, 2015 at 5:33

© 2022 - 2024 — McMap. All rights reserved.