Use Stack Overflow for Teams at work to find answers in a private and secure environment. Get your first 10 users free. .

Questions tagged [future]

A placeholder for the result of a calculation before the calculation has completed. Used in concurrent programming. Questions about future events are off-topic on Stack Overflow.

Filter by
Sorted by
Tagged with
1
vote
1answer
36 views

When to use Scala Futures?

I'm a spark Scala Programmer. I have a spark job that has sub-tasks which to complete the whole job. I wanted to use to Futures to complete the subtasks parallelly. Once completion of whole job i have ...
0
votes
0answers
27 views

Flutter: Start Game with Future<Int> as default Level

I want to create a game. In this Game i try to get the default level from the persistent storage via SharedPreferences. The game have to start, after the value is set as an integer. I don't know how ...
1
vote
2answers
32 views

Future[Option[T]]: Keep future if Option is defined otherwise fallback to another future

I have this val cacheElement:Future[Option[T]] and the desired result is to keep this future if the Option is a Some or create another Future[Option[T]] based on another service if the future is a ...
-1
votes
1answer
53 views

Computation with Futures avoiding Await method

I have funtion which is calling computeParallel() function which is calling 3 Futures F1,F2,F3 and returning String as return type. def computeParallel():String = { val f1 = Future { "ss" } ...
1
vote
0answers
36 views

How to fetch a document data and set it on screen

I'm trying to fetch certain information from a firebase object (like the name) but the build doesn't wait for the future, nor changes it afterwords I've tried both using a Future and a Stream (I'm ...
0
votes
0answers
17 views

Asynchronous API endpoints with plumber

How do I define asynchronous API endpoints in plumber? I didn't really find plumber-specific documentation on the topic except this example and this GitHub issue When I try to reproduce the example, ...
0
votes
2answers
95 views

Parallel Computation with Scala Futures [on hold]

I have a Function that computes two sub-functions like this. def someFutureMethod1(input: Int): Int = { input + 1 } def someFutureMethod2(input: Int): Int = { input + 12 } def ...
0
votes
0answers
21 views

Java limit Future computation time [duplicate]

I have a completable future, which is then used by some external libraries/clients. CompletableFuture.supplyAsync(() -> { // do smth }, threadPool) I want future to be rejected if it is running ...
0
votes
0answers
21 views

Scala Futures to return response to Jobserver API

I have a LongRunning Spark job with multiple sub-jobs and i wanted to return the results to API client as soon i have completed every sub-job.Updating the response to API Client I'm trying to ...
0
votes
0answers
25 views

Flutter Page view not updating in Future Builder async snapshot

I am using the code from -> https://github.com/aaronksaunders/simple_firebase_auth/tree/master/lib When I log in using Firebase, I would like the page to automatically redirect to the HomePage. ...
0
votes
1answer
34 views

How to query data from Firebase with an async call to uid

I'm trying to fetch data that belong to the logged in user, however, the "getuserui" is async, for some reason. even though the user is logged in to do stuff inside the app the function still returns ...
1
vote
2answers
42 views

Create a packaged_task of function object

How to create a packaged_task of a function object ? For example, class TaskA { public: std::function<int(void)> func; TaskA(std::function<int(void)>&f) : func(f) ...
1
vote
1answer
25 views

Merge Firestore's separate queries Streams in Dart

I'm implementing a Todo Application in Flutter. I need to merge a double query in client, in order to perform an OR request in Firestore. One hand, I have the following code that performs the double ...
2
votes
1answer
30 views

Catching throwables vs exceptions before calling CompletableFuture.completeExceptionally(Throwable)

I know the web is full of advice not to catch Throwables, but does it apply when working with CompleteableFutures? For example, in ExecutorService es = Executors.newFixedThreadPool(2); ...
0
votes
1answer
28 views

Waiting for Future to be Complete in HTTP GET

I am trying to return a temperature conversion as a HTTP GET request and display it. Currently I do not think it is waiting for the future to complete. If I try and add the onComplete callback then it ...
1
vote
0answers
21 views

Flutter: How to pass a TextField text to an API request?

I am learning Flutter, so I made a fun little News app with the news API. It has different tabs for different categories and it requests the data based on the keyword associated with each tab. However,...
0
votes
1answer
20 views

Analog of Promise.all in Dart?

Is there an existing API to group a list of Future object into one so that I can wait for all to complete? Like in javascript's Promise.all.
1
vote
0answers
32 views

Future<Integer> object accepts a return type of String. How? [duplicate]

I have two callable objects. one returns an Integer, and the other returns a String. I am using the ExecutorService for running them. public class MyExecutor { public static void main(String[] args) ...
1
vote
1answer
55 views

How do I wrap a blocking function into a promise RShiny

I have an R Shiny dashboard that has 2 observers that are set to refresh at specific times, One observer refreshes every 6 hours, the other every 2 mins. Both observers run a function that returns a ...
0
votes
1answer
19 views

Access the API response and print it on button click in flutter?

In login API it returns response, I want to get the response in button onclick and print it. How can I do this? onTap: () async => { await propertyBloc.fetchAllCategory(); ...
0
votes
0answers
13 views

How to cancel futures created through one http request by sending another http request

I send http request through angular ajax. It creates futures list and start execution I want to cancel it before all futures are completed How can i do that? If i send another http request, ...
1
vote
2answers
55 views

How to avoid next functions in the pipeline while using futures

What is the optimum way to stop/skip the following function based on the current result from a future value? Assume I have 3 function which returns Future[Boolean] like this: def funA() : Future[...
0
votes
1answer
55 views

Multiple Call Async for update vector or list in C++

I am stuck in multiple Async problems like that example: void updateList(vector<int> &list, int value){ list.push_back(value); } int main(){ vector<future<void>> ...
-1
votes
1answer
24 views

Tomcat allocates a new thread per HTTP request so what's the motivation of using future.get()?

I know tomcat server container, allocates a new thread for every new HTTP request.Then what's the motivation behind the use of callable + future? 1) Why do we care if the only thread for the current ...
2
votes
0answers
64 views

How to map Array of EventLoopFuture<Type> to Array of EventLoopFuture<OtherType> in Vapor

I have a Vapor backend that I wrote a few tests for. The test code looks like this: func testFollowUser() throws { user = try user.save(on: conn).wait() let userToFollow = try ...
1
vote
1answer
25 views

Issue with retrieving elements using FutureBuilder

I'm new to Flutter and trying to use a FutureBuilder in my project. I am trying to build a ListView with a list of elements from Cloud Firestore, so I'm using asynchronous functions to get the data ...
0
votes
0answers
18 views

How to let tomcat main thread get more clients' request instead of sleeping for future.isDone()

I read about Callable and Futures in java. I want to run a java web-server that does some background callable. I have a few questions: 1) future.get() blocks my main thread. while (!future.isDone(...
0
votes
1answer
19 views

When removing items from futurebuilder it doesn't update

I have a futurebuilder that calls an API connected to DynamoDB. When I remove an item from dynamoDB however it doesn't update my list unless I navigate away from the screen and then come back, ...
1
vote
1answer
34 views

What missing functionality and traits do I need Spawn_ok with a clonable object?

I'm experimenting with futures 0.3 for the first time, and getting trait or lifetime issues. use futures::executor::ThreadPool; use futures::future::*; use futures::StreamExt; const BUFSIZE: usize = ...
0
votes
2answers
26 views

type 'future<dynamic>' is not a subtype of type 'function'

when i run my app in debug mode it shows me the error "type 'future' is not a subtype of type 'function'" all over the screen and also in the debug console. Can someone help me? I imagine it's a ...
0
votes
0answers
19 views

Nested future on remote machines

In my package I have a function that roughly works like that: f <- function(files) { futures <- vector("list", length(files)) for (file in files) { futures[[i]] <- future::future({ ...
1
vote
1answer
68 views

Is it possible to convert synchronous function call with output of Either[Throwable, Unit] to Future[Either[Throwable, Unit]]?

I have this scala function that produces Either[Throwable, Unit] in which there is a retry call. The someClient.insertDetails function returns an entity; not a Future or anything, just an instance of ...
0
votes
0answers
22 views

How to catch nested async/await exceptions properly?

I have some async procedures which call another async procedures. I have a some main procedure which waits for all futures returned by above mentioned procedures to be completed. After completion I ...
0
votes
1answer
47 views

View result of Scala Future for side effects

I have a method that returns a Future. I want to log success or failure based on it, and then process the result. In Java with streams, I would do something like getCollection().stream(). peek(e -...
0
votes
1answer
52 views

Map the exception of a failed future to Some, but isDefined does not work

I just encountered a strange problem of scala. I mapped the exception of a failed future to Some type, but the isDefined function does not work for the Some variable. The code is just for testing: ...
0
votes
1answer
24 views

Java : guava Futures API with ListenableFuture

I'm trying having a better understanding of guava API with easy example : First I instantiate ListenableFuture that returns "hello" Then I use Futures.transform() to transform my "hello" into "HELLO" ...
1
vote
1answer
25 views

why @Asynchronous and Future Class does not work

I am trying to call asynchronous method that returns Future Object, I suppose that it will print YYY and then XXX since the XXX is in a method that is 1 sec long. however, after deploying the code, it ...
0
votes
2answers
57 views

Getting NULL value for async function (after using await) then updating to the new value

When I run my app it throws a lot of errors, and the red/yellow error screen on my device, which refreshes automatically and shows me the expected output then. From the log I can see that first my ...
0
votes
0answers
21 views

Deserializing Finagle Response

I'm writing Unit Test for a Finagle Controller and I'm having a hard time deserializing the Response from a twitter Future in order to validate. When I print the Future, I can see all the content, but ...
2
votes
1answer
72 views

Why does std::future::wait_for not behave as expected?

#include <iostream> #include <chrono> #include <future> using namespace std::literals; int main() { std::promise<void> prom; auto fut = prom.get_future()...
2
votes
0answers
292 views

How to replace combinators with Future?

I have a function which returns Future. It accepts another function which accepts one argument and returns Future. Second function can be implemented as combinators chain passed into first function. ...
0
votes
1answer
51 views

Manually polling streams in future implementation

I'm in the process of migrating to futures 0.3 and tokio 0.2, and there is one recurring pattern I can't manage to re-use. I'm not sure whether this pattern became obsolete or whether I'm doing ...
0
votes
2answers
69 views

Is parallel processing a solution for RAM shortage in R due to a large dataset?

I would like to do several machine learning techniques (logistic regression, SVM, Random forrest, neural network) in R on a dataset of 224 GB while my RAM is only 16 GB. I suppose a solution could be ...
0
votes
0answers
16 views

How does folly future achieve to chain async callbacks?

I read from an Instagram blog that with folly future, you can do: doIO1(io1Input) .then([..](Data io1Result) { return doIO2(io1Result); }) .then([..](Data io2Result){ return doIO3(io2Result); }) ....
0
votes
0answers
32 views

Mocking types that are template parameters of return types for methods that I also need to mock

I'm writing some code that uses a 3rd party library. The library in question provides an API in terms of concrete classes, not interfaces. This makes it difficult to write tests that would target MY ...
1
vote
1answer
62 views

Unable to render “loading” using Shiny and futures

I am trying to use futures to have a "loading" icon appear. This is the code I have library(shiny) library(promises) library(future) plan(multiprocess) disksUI <- function(id) { ns <- NS(id)...
0
votes
0answers
27 views

How to use asyncinterruptor in the ipc package to stop a child process in Shiny?

I'm writing a Shiny application and would like to set up a cancel button to stop executing a certain function while keeping the Shiny process. I have referred to this article and articles about ...
0
votes
0answers
73 views

How do I use Pin with Tokio's Sink?

I would like to create a method sending some data on a struct which implements Tokio's Sink, but I'm having problems working with Pin as self. In essence, I need something like this: fn send_data(&...
0
votes
0answers
24 views

detecting crashes of a std::packaged_task

I want to detect if a packaged task successfully completes, but have a few edge cases when errors in the task cause the thread to crash (from some 3rd party codes). In these cases no exceptions are ...
0
votes
1answer
22 views

How do I compose nested case classes populated with async mongodb queries in play framework

I have been trying to convert mongodb queries I have working with await to using totally async. The problem is, I cannot find any examples or get code working to populate a list of objects where for ...