Questions tagged [asynchronous]

Asynchronous programming is a strategy for deferring operations with high latency or low priority, usually in an attempt to improve performance, responsiveness, and / or composability of software. Such strategies are usually employed using some combination of event-driven programming and callbacks, and optionally making use of concurrency through coroutines and / or threads.

Asynchronous programming is a strategy for deferring operations with high latency or low priority, usually in an attempt to improve performance, responsiveness, and / or composability of software. Such strategies are usually employed using some combination of event-driven programming and callbacks, and optionally making use of concurrency through coroutines and / or threads.

Asynchronous programming is used in many situations:

  • handling user input in UIs and games,
  • processing network traffic,
  • performing disk I/O,
  • batching work,
  • and more.

Asynchronous programming models can aid in software composition in many languages (notably languages where functions are first-class types) and APIs providing callback-based completion messaging. Proper use of this programming methodology can improve throughput and improve responsiveness by reducing total latency of job batches when executed in parallel. This approach can also result in an increase in system throughput at the cost of increased operational latency resulting from deferred processing.

50995 questions
13
votes
2 answers

Async method not waiting for a function - VUE

i'm having this error and haven't got to resolve it though have researched a lot in MDN and here. As title saysinto VUE i'm trying to use async and await but js is not waiting the 'await' function to end. Here it is: methods: { async search…
Leo Prada
  • 160
  • 1
  • 2
  • 9
13
votes
2 answers

Reading a csv file async - NodeJS

I am trying to create a function where I can pass file path and the read the file in async way. What I found out was that it supports streams() const fs = require('fs'); var parse = require('csv-parse'); var async = require('async'); readCSVData =…
Samuel
  • 1,128
  • 4
  • 14
  • 34
13
votes
4 answers

How can I use a event emitter as an async generator

I'm trying to use the neat syntax of async generator with babel (I'm stuck with node 8) and I'm wondering how you would convert an event emitter to an async generator cleanly What I got so far look like this const { EventEmitter } =…
Overcl9ck
  • 828
  • 7
  • 11
13
votes
1 answer

Safe way to implement a "Fire and Forget" method on ASP.NET Core

I am trying to implement a simple logging library which will be used across multiple projects. The job of library is to send HTTP requests to ElasticSearch. The main point of this library is that it must not wait for the response. Also, I don't care…
Nomad
  • 313
  • 2
  • 4
  • 18
13
votes
2 answers

How can I grab Google Visualization DataTable data after chart is loaded?

I want to grab Google Chart data from a page, convert it to CSV, and then hand it off to a downloader. In chartpage.js function downloadCSV(args) { var csvData, filename, link; var action = args.action_name; var csv =…
13
votes
2 answers

Promises/Fetch in JavaScript: how to extract text from text file

I'm working on a small program in JavaScript. Basically, I want to use Promise and fetch to extract text out of two text files. However, I can't figure out how to get the actual text out of the files. Here's my current code. sample.txt this is a…
Leia_Organa
  • 1,894
  • 7
  • 28
  • 48
13
votes
1 answer

calling an async function in the constructor.

getUser is an async function? if it is going to take longer time to resolve? is it going to always return the right value in my someotherclass. class IdpServer { constructor() { this._settings = { // some identity server…
hashbytes
  • 769
  • 1
  • 8
  • 26
13
votes
1 answer

Call an async function in an normal function

I'm pretty new to the asyncio for python 3.6 So the thing is I have a class and I want to init some property in there. And one of the property is the return value from an async function. What's the best practice to do this? Call event_loop one time…
qichao_he
  • 4,204
  • 4
  • 15
  • 24
13
votes
2 answers

Asynchronous model in grpc c++

My team is designing a scalable solution with micro-services architecture and planning to use gRPC as the transport communication between layers. And we've decided to use async grpc model. The design that example(greeter_async_server.cc) provides…
WhiteSword
  • 155
  • 2
  • 5
13
votes
7 answers

How to use Micrometer Timer to record duration of async method (returns Mono or Flux)

I'd like to use Micrometer to record the execution time of an async method when it eventually happens. Is there a recommended way to do this? Example: Kafka Replying Template. I want to record the time it takes to actually execute the…
Mark
  • 4,970
  • 5
  • 42
  • 66
13
votes
6 answers

React Native - Return all JSON data in AsyncStorage?

In my React Native app's AsyncStorage, I have multiple JSON objects, each with a unique key id like so: '62834456': data: { "foo": "bar", "nicknames": [ "grizz", "example" ], ... and so on } They have been pushed into AsyncStorage stringified.…
zahnzy
  • 237
  • 1
  • 2
  • 13
13
votes
2 answers

Javascript async function console log the returned data

How can I console log - or do any thing with the data returned from inside an async function? example: JS FILE: async function getData(){ try { $.getJSON('./data.json', (data) => { return data; }); }…
Sergio
  • 792
  • 3
  • 10
  • 35
13
votes
4 answers

Why does this JavaScript async/await code not behave as expected?

I've tried reading guides and tutorials to async/await, but I can't seem to find this addressed anywhere. Here is the code in question: var func1 = new Promise((resolve, reject) => { console.log("Func1"); setTimeout(() => { …
HanifC
  • 175
  • 7
13
votes
1 answer

How to use multiple threadPoolExecutor for Async Spring

I am using Spring @Async on two classes. Both are ultimately implementing an interface. I am creating two separate ThreadPoolTaskExecutor so each class has its own ThreadPool to work off of. However due to I think something with proxy and how Spring…
Kirit
  • 389
  • 2
  • 3
  • 11
13
votes
2 answers

Which is the most efficient way to iterate a directory?

Say I have a directory foo, with some number of subdirectories. Each of these subdirectories has between 0 and 5 files of variable length which I would like to process. My initial code looks like so: pool.query(` SET SEARCH_PATH TO…
Abraham P
  • 15,029
  • 13
  • 58
  • 126