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
3 answers

Does boost::asio::io_service preserve the order of handlers?

Does boost::asio::io_service guarantee that handlers are called in the same order that they are given via post()? I can't find anything saying this in the documentation. Assume that calls to io_service::post are serialized.
jakar
  • 1,031
  • 1
  • 11
  • 22
13
votes
3 answers

React Formik onSubmit Async called twice

I am trying to use async with onSubmit with following code for Formik in React import React from "react"; import { Formik, Form, Field } from "formik"; import { Row, Col, Button } from "react-bootstrap"; const AddUser = () => { const…
Manoj Sethi
  • 1,898
  • 8
  • 26
  • 56
13
votes
2 answers

How do I make parallel async HTTP requests using httpx (versus aiohttp) in Python?

This was based on a typo, and simple mistake. Not deleting since it has sample code for httpx. I'm attempting to leverage asyncio to parallelize several long-ish running web requests. Because I'm migrating from the requests library, I would like to…
Steven Borg
  • 641
  • 1
  • 6
  • 14
13
votes
2 answers

Task.Factory.StartNew() vs. TaskEx.Run()

Task.Factory.StartNew() basically receives an Action and returns a Task. In The Async CTP we have TaskEx.Run() which also receives an Action and returns a Task. They seem to do that same thing. Why TaskEx.Run() was introduced ?
Yaron Levi
  • 12,535
  • 16
  • 69
  • 118
13
votes
3 answers

How can I run an elisp function asynchronously?

for those who don't know, imenu is a thing in emacs that lets a mode insert one or more menu items into the menu bar. The most common usage is to make a "table of contents" accessible from a drop-down menu, so the user can quickly jump to…
Cheeso
  • 189,189
  • 101
  • 473
  • 713
13
votes
2 answers

Spring boot Async with Multithreading

I have a spring boot microservice where we call multiple services(Lets say Service A and Service B). I am trying to call these two services Asynchronously on multiple threads based on some conditions and once processing is completed I would like to…
JingJong
  • 207
  • 1
  • 3
  • 14
13
votes
3 answers

Truly asynchronous file IO in C++

I have a super fast M.2 drive. How fast is it? It doesn’t matter because I cannot utilize this speed anyway. That’s why I’m asking this question. I have an app that needs a real lot of memory. So much that it won’t fit in RAM. Fortunately it is not…
janekb04
  • 4,304
  • 2
  • 20
  • 51
13
votes
1 answer

When to use Task.Run().GetAwaiter().GetResult() and ().GetAwaiter.GetResult()?

I have an async Task that needs to be called synchronously (yes, unfortunately, it is unavoidable). It seems that there are two ways of implementing this - each seeming to work. So I'm unsure which is the best approach, or if there is a better…
Adam
  • 370
  • 1
  • 5
  • 11
13
votes
1 answer

Warning: No such label 'RESPONSE TIME' for console.timeEnd()

Situation: I have a Node.js api that is called many times a second on a website. I am using console.time('RESPONSE TIME') and console.timeEnd('RESPONSE TIME') to measure how long the api is taking to respond to the client on to each request. Inside…
Ryan Walker
  • 715
  • 2
  • 10
  • 23
13
votes
1 answer

What's the difference between returning void vs returning Future?

Is there a difference between an async method that returns void, and one that returns Future? It seems that both are valid in Dart: void main() async { await myVoid(); await myFutureVoid(); } void myVoid() async { // Do…
Magnus
  • 17,157
  • 19
  • 104
  • 189
13
votes
5 answers

Asynchronous and synchronous HTTP request on server side, performance comparison

I am trying to figure out the pros and cons of asynchronous and synchronous HTTP request processing. I am using the Dropwizard with Jersey as my framework. The test is comparing the asynchronous and synchronous HTTP request processing, this is my…
Jade Tang
  • 321
  • 4
  • 23
13
votes
1 answer

Where do I catch the KeyboardInterrupt exception in this async setup

I am working on a project that uses the ccxt async library which requires all resources used by a certain class to be released with an explicit call to the class's .close() coroutine. I want to exit the program with ctrl+c and await the close…
iuvbio
  • 600
  • 6
  • 23
13
votes
2 answers

await outside of async function doesn't throw error in console

MDN says: Remember, the await keyword is only valid inside async functions. If you use it outside of an async function's body, you will get a SyntaxError. But that's not true. Try this code in DevTools console, no errors, just result: async…
Green
  • 28,742
  • 61
  • 158
  • 247
13
votes
3 answers

async function with the class in javascript

I have create a class in nodejs class ApnService { sendNotification(deviceType, deviceToken, msg, type, id) { try { const note = await apnProvider.send(note, deviceToken) console.log(note) } catch (err) { …
13
votes
1 answer

how is asyncio.sleep() in python implemented?

I'm a newbie python3 enthusiast, who hopes to find out how asyncio.sleep() is implemented by the library. I'm capable of writing coroutines but I can't seem to think about how to start writing code for asynchronous sleep. would be great if you…
laycat
  • 5,381
  • 7
  • 31
  • 46