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.
3,855
questions
0
votes
1
answer
70
views
Can multiple threads copy a std::shared_future at the same time?
Is a shared_lock enough in GetNextImage(), or do I need to use a unique_lock?
shared_future<Mat> shfutNextImage;
shared_mutex shmutNextImage;
shared_future<Mat> GetNextImage()
{
...
1
vote
1
answer
64
views
Implement an async builder pattern in Rust
I want to implement a future for a builder. This can be common for examples such as configuring a request via a builder, then sending it off.
I want to implement IntoFuture for a builder but I cannot ...
0
votes
0
answers
9
views
Time Series Binary Prediction
I want to create a model to predict customer departure (churn) based on monthly time-series data.
My data does not contain direct labels indicating churn, so I am considering using revenue (income) as ...
-2
votes
0
answers
20
views
Cybersecurity and its future in upcoming years [closed]
I'm a student presently pursuing a B.Tech in computer science and passionate about cybersecurity. I'm planning to purse the same in the upcoming semester and want to make my career in same field. ...
0
votes
0
answers
40
views
How to time a ListenableFuture
I want to track how long an async process takes.
My general approach for synchronous processes is to record the current time, run the process, and finally calculate and record the difference. I use an ...
0
votes
2
answers
42
views
async keyword Future<dynamic> problem in flutter/dart . I just want to know how the code is generating an error here below
I dont know what is happening in this portion of code:
Future fnct() {
print("inside fnct()");
return Future.delayed(Duration(seconds:4),()=>"hello");
}
Future fnct2() ...
-1
votes
0
answers
25
views
How do you wait for a Future object resulting from an API call to terminate?
I'm trying to wait for the results of a query to the api of my gradio chatbot but I don't know how to do it. I mean waiting for a Future object to complete. I thought .result() would wait for the ...
0
votes
2
answers
42
views
Flutter/Dart Future
class _WorterBuchState extends State<WorterBuch> with TickerProviderStateMixin {
var wordPair= '' ;
@override
void initState(){
super.initState();
load();
}
Future<void> ...
1
vote
0
answers
31
views
How do I Wrap Functions Presented by plumber for Work in Promises
I have about 20 typical functions like:
echo_delayed <- function(j){
jj <<- j # for debugging purpose
Sys.sleep(1.5)
print(paste0('echo_delayed - ', now() %>% toString(), " &...
0
votes
1
answer
33
views
I have two queueable jobs running in a transaction how to resolve it
On Order Product object I have an integration with a 3rd party system, which sends data the 3rd party whenever the Order Product through Queueable class.
Now I am trying to insert a set of records to ...
0
votes
1
answer
91
views
Forcing a QiChatbot to reply to a phrase typed by the user
I am working on a Pepper application on android that uses a QiChatbot to communicate with users about minerals. I want to make the chatbot also available for on-screen use for people with hearing and/...
2
votes
2
answers
38
views
Future and DispatchQueue generating build error
I am trying to build a swift app, and I am opening a JSON file. As it could be time-consuming on the main thread, I want to do it in background.
Here is the call I am doing using Future and ...
0
votes
2
answers
38
views
Get worker name from multisession framework provided by future package
I am parallelizing the data analysis via multiplesession plan of future package. The dataset is large. I tried to let each worker return the model fitting output to the main R session, and write the ...
0
votes
0
answers
16
views
how to calculate the future in a past period? pine script
I am trying to convert to pine script the following thinkscript indicator which checks and calculates a current value based in past periods (where available data is available) and I have not found out ...
0
votes
1
answer
59
views
Feed subtasks with values, how to do?
I want a main thread which can give values to a number of subtasks (where the subtasks takes long time to execute) and where I do not want to end the subtasks and restart them with new values.
I try ...
2
votes
1
answer
51
views
Flutter pass dynamic snapshot to another page
I have a page where I get snapshot returned as Future<List<RaceModel>>. Then on my widget I use a ListView.builder to display the data, which is ok:
class _DashboardState extends State<...
3
votes
1
answer
80
views
How does Ctrl-C work with multiple processes in python?
I am trying to distribute work across multiple processes. Exceptions that occur in another process should be propagated back and handled in the main process. This seems to work for exceptions thrown ...
0
votes
0
answers
22
views
Future that returns large data works on emulator but not physical device
I have a page that returns a list of audio files on the host device and i want to use the details of these files to create a list of audio files but it doesn't work on physical device(keeps loading) ...
0
votes
0
answers
56
views
List[Future[A]] => Future[(List[A], List[Throwable])] the most correct solution
I have solution:
def foo[A](futures: List[Future[A]])(implicit ec: ExecutionContext): Future[(List[A], List[Throwable])] =
futures.foldLeft(Future.successful(List.empty[A] -> List.empty[Throwable]...
0
votes
2
answers
57
views
Using Future blocks UI in application
In my Android app I want to use java.util.concurrent tools to make operations that return value (for educational purposes). I read that CompletableFuture can be used for this. I made a project where I ...
0
votes
0
answers
83
views
std::future::wait_for returns immediately timeout while the time duration has not elapsed
I have encountered an issue related to std::async and std::future::wait_for.
I have the following code
auto future = std::async(std::launch::async, [&](){return myfunction();});
auto status = ...
0
votes
1
answer
38
views
Limit of workers in future::plan() function higher than available CPUs cores
I have a CPU of 8 cores which I'm trying to use to do parallel future_map_chr().
My question is as follows: the number of cores in my computer is equal to 8, so how is it possible to parallelize ...
0
votes
0
answers
57
views
Trait bound's problem while processing Result<Vec<u8>, Box<dyn Error>>
I'm trying to build a matrix bot using matrix-rust-sdk based on the following example.
use std::error::Error;
use matrix_sdk::{
self,
attachment::AttachmentConfig,
config::SyncSettings,
...
2
votes
0
answers
42
views
pass an async function into another async function in rust that return different types of results [duplicate]
I would like to write an async function that takes in another async function as a parameter:
async fn do_sth_else(_ref: &str, _db: &DatabaseConnection) -> Result<i32, AppError> {
/...
1
vote
0
answers
41
views
Confused when using the completableFuture for reading the file
I tried to estimate the performance between async and sync.
I wrote some easy async code which is reading the file and printing the result.
I divided them into two parts, one is reading the file and ...
0
votes
1
answer
27
views
flask_executor future.result() throws TypeError: 'str' object is not callable
I'm trying to get result from the process that I created to run in the background using flask_executor. This are methods in use:
def scan_and_collect( self ):
self.data_collector.collect()
...
0
votes
1
answer
50
views
Interrupt underlying execution of CompletableFuture
I havw this piece of code:
CompletableFuture<Void> timeoutFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
.orTimeout(1, TimeUnit.SECONDS); // Set a ...
0
votes
2
answers
67
views
Dart: Explain SynchronousStreamController with an example
I have gone through the doc of SynchronousStreamController manytimes.
I know that it delivers its events synchronously; events are fired immediately to the stream instead of adding to a later micro-...
0
votes
1
answer
57
views
Mutating vector's element in place using async Rust
Let's say I have a basic struct:
pub struct Course {
pub id : i32
}
I want to modify this struct's inner elements. Let's say earlier I have read from a database and read Course's into a vector.
...
0
votes
1
answer
36
views
How does Dart run asynchronous code like Future and Stream if is single thread?
I'm having some trouble understanding Dart asynchronous programming.
According to documentation, Dart is single-threaded, so it only has one thread, which they call Isolate.
Now, we can create a new ...
0
votes
3
answers
61
views
Is it fine to use Future delayed in my function to allow previous functions to finish their process?
I'm currently new to Flutter and Dart. I have functions that need to be finished before another function is executed. Is it reasonable to use Future Delayed to delay that specific function? Is there ...
0
votes
0
answers
23
views
Why is the return value of a function with a multisession future different in plumber?
When comparing the first two code snippets below it is apparent that the do.call() setup will not return 4 but rather an object from the futureverse. On the other hand the plumber setup seems to ...
0
votes
0
answers
58
views
Error: Bad state: Future already completed while awaiting for futures to complete - how to catch?
I am having this exception on iOS (Android's OK):
flutter: Error: Bad state: Future already completed
And I am trying to understand and fix it.
Therefore I wanted to know:
How to catch this error? ...
1
vote
2
answers
46
views
How to clone Future in Dart/Flutter
I have a custom FLutter widget that receives a future as a parameter to it's constructor and has FutureBuilder inside.
I want to add the ability to rerun this future in case of connection error, but ...
0
votes
0
answers
32
views
What is an absolute and long-lasting time reference for my computer?
I'm coding a time capsule app in C++. One key feature it needs is to be able to check the date and time with total certainty, most definitely from a trusted (official?) online server (which one?).
...
0
votes
0
answers
17
views
How to pass generic value returned from Future object to a callback function with specific parameter type [duplicate]
I am learning Java Future API. I want to write a generic Future handler code that gets any value from a Future and passes it to a callback function. To elaborate, if below is a generic function that ...
0
votes
2
answers
93
views
Flutter: Future.wait does not seem to work
I build a widget on my front page which relies on information I receive from Firebase.
Because this widget can not display properly without the information from the database (dates, picture URLs, etc.)...
2
votes
0
answers
63
views
Single-threaded asynchronous code in C++17
I am developing a kind of smart UDP/TCP proxy for a very limited device with embedded Linux. The device has a prescribed SDK, therefore i am limited to GCC C++17, can't use Clang or C++20. I have the ...
0
votes
1
answer
68
views
How to extract the return value from THEN in flutter?
I want to return one single user from two different user collections inside Stream function. Now, I need to extract the value comes from .then((value) => ... ), so I can return it.
In the code ...
0
votes
1
answer
42
views
Why FutureBuilder never reload data when it changed in Flutter
I try to upload an image inside FutuerBuilder in flutter but nothing happen to the UI. I have to leave the current page and enter it again to see changes. That is happenn in uploading the image, but ...
-1
votes
2
answers
53
views
CompletableFuture runs out of order
I have the following code in Java (I use Oracle Java 17):
package com.test;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
public class Solution {
public ...
0
votes
0
answers
53
views
QFutureWatcher doesn't emit signals as expected
I can't get QFutureWatcher to emit any signals when watching a future.
The simple snippet seen below prints Result: 1 as expected but neither of the two connected lambdas are ever called.
What am I ...
0
votes
1
answer
26
views
Why do I have to hot reload flutter for the future builder to return
I have a problem where when i launch the assignment page from the phone no List is returned by the future but when I hot reload a list is returned.
Here is the Future code that fetches the list from ...
1
vote
1
answer
58
views
Converting monix.eval.Task to scala.concurrent.Future
I’m trying to reuse some module that uses monix.eval.Task for async tasks.
My project uses scala.concurrent.Future.
I'm trying to understand the best way to convert it to Future with the least amount ...
0
votes
1
answer
59
views
Rust equivalent of Python Future (i.e. with set_result() method)
Is there a struct in some well-known utilities crate that does what Python's asyncio.Future does, i.e has a .set_result(value) method, and will be pending indefinitely until some other task calls that ...
1
vote
0
answers
47
views
Do canceled Futures in Rust stop at non-await points?
When a running future is cancelled from another thread, will it interrupt the execution of code, or continue until it hits an await point to stop?
async fn hellos() {
use tokio::time::*;
for ...
0
votes
1
answer
65
views
what is the difference between Future<void> and void [duplicate]
I'm writing a code in flutter and don't know what is the difference between them
` Future senddata(BluetoothDevice d) async {
BluetoothConnection? connection;
connection = await ...
5
votes
1
answer
84
views
Why does js_sys Promise::new require FnMut?
js_sys exposes JavaScript Promise via a function pub fn new(cb: &mut dyn FnMut(Function, Function)) -> Promise;. Per my reading of the MDN documentation, there's nothing suggesting that the ...
0
votes
1
answer
59
views
A bit confusing compiler error message around Boxed Future in Rust
I don't seem to understand the compiler error message here. For the following snippet
use std::pin::Pin;
use std::future::Future;
fn give_future<'a>(x : &'a i32) -> Pin<impl Future<...
0
votes
1
answer
41
views
FutureBuilder causing error in DropDownButton after SetState
I have this:
List<Students> studentList= [];
Future<List<Students>> getJsonData() async {
final String response = await rootBundle.loadString('assets/students.json');
final ...