Questions tagged [asynchronous-programming]
The asynchronous-programming tag has no summary.
185 questions
99
votes
1
answer
64k
views
Is there really a fundamental difference between callbacks and Promises?
When doing single-threaded asynchronous programming, there are two main techniques that I'm familiar with. The most common one is using callbacks. That means passing to the function that acts ...
58
votes
8
answers
9k
views
Are events only used for GUI programming?
Are events only used for GUI programming?
How do you handle in normal backend programming when something happens to this other thing?
51
votes
4
answers
14k
views
Who did async/await first?
Python added the async/await constructs in 3.5 in 2015. The Javascript community made steps towards it for a bazzillion years and finally added a very similar implementation to the draft in ES8 ...
48
votes
5
answers
37k
views
async+await == sync?
Stumbled upon this post that talks about making async web requests.
Now simplicity aside, if in real world, all you do is make an async request and wait for it in the very next line, isn't that the ...
34
votes
14
answers
14k
views
Why don't programming languages automatically manage the synchronous/asynchronous problem?
I have not found many resources about this: I was wondering if it's possible/a good idea to be able to write asynchronous code in a synchronous way.
For example, here is some JavaScript code which ...
29
votes
4
answers
18k
views
What determines which Javascript functions are blocking vs non-blocking?
I have been doing web-based Javascript (vanilla JS, jQuery, Backbone, etc.) for a few years now, and recently I've been doing some work with Node.js. It took me a while to get the hang of "non-...
27
votes
3
answers
25k
views
How does Javascript code become asynchronous when using callbacks?
I've been doing a lot of reading online trying to figure out how to write asynchronous JavaScript code. One of the techniques that has come up a lot in my research is to use callbacks. While I ...
24
votes
3
answers
47k
views
Calling multiple async services in parallel
I have few async REST services which are not dependent on each other. That is while "awaiting" a response from Service1, I can call Service2, Service3 and so on.
For example, refer below code:
var ...
24
votes
1
answer
10k
views
Does Akka obsolesce JMS/AMQP message brokers? [closed]
I spent the last week deep diving into the Akka docs and finally understand what actor systems are, and the problems that they solve.
My understanding (and experience with) traditional JMS/AMQP ...
23
votes
4
answers
9k
views
Purpose of async/await in web servers
I don't understand why I keep seeing async/await recommended (or sometimes, even enforced) for ASP.NET Core web applications and APIs.
As far as I can tell, every request is already being run on a ...
22
votes
1
answer
14k
views
Learning Asynchronous programming [closed]
Asynchronous non-blocking event driven programming seems to be all the rage. I have a basic conceptual understanding of what this all means. However what I'm not sure is when and where my code can ...
22
votes
3
answers
9k
views
API Gateway (REST) + Event-Driven Microservices
I have a bunch of microservices whose functionality I expose through a REST API according to the API Gateway pattern. As these microservices are Spring Boot applications, I am using Spring AMQP to ...
14
votes
1
answer
6k
views
How can NodeJS be "non-blocking"?
I'm learning NodeJS and just wanted to clarify something. In several introductory tutorials and books so far, very early on they've described Node's "non-blocking" architecture - or rather that it's ...
13
votes
1
answer
9k
views
Is the C# async/Task construct equivalent to Java's Executor/Future?
I'm a long time Java developer, but with so little traffic on SE, I don't limit my viewing to any single tags. I've noticed that C# questions with async/await come up a lot, and as far as I've read it'...
13
votes
1
answer
2k
views
Blurring the lines between async and regular functions in C# 5.0
Lately I can't seem to get enough of the amazing async-await pattern of C# 5.0. Where have you been all my life?
I'm absolutely thrilled with the simple syntax, but I'm having one small difficulty. ...
12
votes
2
answers
22k
views
Efficient mixing of sync and async methods within a single method?
Okay, it sounds odd, but the code is very simple and explains the situation well.
public virtual async Task RemoveFromRoleAsync(AzureTableUser user, string role)
{
AssertNotDisposed();
var ...
10
votes
8
answers
4k
views
Why is there a shift towards asynchronous and event driven programming?
My question will be mostly about Linux and contemporary X86 hardware.
Clarifying the terms
async event based programming: spawning fixed amount of threads and using some user space scheduling ...
10
votes
1
answer
4k
views
"Reactive programming is programming with asynchronous data streams." is this true?
I was reading about Reactive programming, and came across this article The introduction to Reactive Programming you've been missing with the quote I put in the question title:
Reactive programming ...
9
votes
1
answer
1k
views
When asynchronous tasks make a bad UX
I'm writing a COM add-in that's extending an IDE that desperately needs it. There are many features involved, but let's narrow it down to 2 for the sake of this post:
There's a Code Explorer ...
8
votes
5
answers
4k
views
Expensive constructors. Should they exist? Should they be replaced?
Suppose I have a constructor that performs an expensive IO operation that takes a noticeable amount of time. I don't like it for a few reasons (first of all, it's simply wrong, but there are practical ...
8
votes
1
answer
596
views
Language compiled to JS – most elegant way to do synchronous-style waits
I'm trying to make (yet another) language that compiles to JavaScript. One of the features I'd like to have is the ability to perform JavaScript's async operations synchronously (not exactly ...
7
votes
3
answers
5k
views
Why is it necessary for every new api to be async?
I'm expressing my frustration here somewhat, but why do many new libraries only have asynchronous APIs? For example I'm creating a small utility to fetch a web page and parse some data from it. ...
7
votes
3
answers
1k
views
Why do many languages semantically distinguish "async" functions from "non-async" ones?
I've seen this in C#, Hack, and now Kotlin: await or an equivalent operation can only be performed in special "async" contexts. Return values from these are, to borrow Hack's terminology, "awaitable" ...
7
votes
1
answer
6k
views
Does omitting await keyword once in the call stack break the asynchronous behavior of the whole stack?
Call stack may contain several methods returning Task. If all of them are decorated with async, the flow of execution is quite simple. However, what if one of them is not awaited - are other method ...
7
votes
1
answer
2k
views
How can we calculate Big-O complexity in Functional & Reactive Programming
I started learning functional programming, I am trying to compare between different algorithms that are written in an imperative, functional , parallel programming and using Collections and Lambda ...
7
votes
1
answer
478
views
API design: stream objects vs. functions vs. messages
I'm designing API for a python library that accepts asynchronous input and produces the asynchronous output: various signals come in, and various signals are generated in response (there's no one-to-...
6
votes
2
answers
584
views
How is async implemented natively?
How is async logic implemented natively without threads? What would be the high level structure of the system?
Is it just a separate OS thread that gets and pushes requests and results in 2 queues?
I ...
6
votes
1
answer
1k
views
Functional programming pattern for async JavaScript code
I have adopted a pattern in one of my projects that I really like and I suspect it's likely to be something standard. I'd like to describe it here and see if you guys can tell me how other ...
6
votes
2
answers
1k
views
Synchronous facade hiding asynchronous web service
I'm maintaining a system providing a typical synchronous web service REST API. It routes each request to one of several possible backend services. Now there is a new backend I want to use, but there ...
6
votes
1
answer
2k
views
How is one supposed to deal with the intermediate buffer of DataReader class?
Summary
I am developing a WAV file format reader under WinRT, and for this I need to read random amounts of structs consisting of fundamental types such as int, uint, float and so on.
Back in ...
6
votes
1
answer
3k
views
UML: Should an asynchronous request-response message exchange be modelled as two ports/interfaces or one
I want to model an asynchronous request-response message exchange in UML.
The request is sent from a client to a server. The server responses asynchronously.
This can be modelled in a component ...
6
votes
2
answers
4k
views
Is it good approach to await async tasks in object destructor?
I'm currently working on class with some async tasks under the hood. In fact I need to delegate few tasks to asynchronous execution and be sure that all of them are finished before class was destroyed,...
6
votes
1
answer
1k
views
Best practice for parameters in asynchronous APIs in Java
Is there a best practice for using Guava's ListenableFuture in parameters in API calls? Compare these two versions of an interface that internally does a compare-and-set (I'm using Guava's ...
5
votes
4
answers
4k
views
How do I know if my async function is truly asynchronous?
I'm writing a function in the node.js-style asynchronous way, but how do I know if these functions are truly asynchronous, i.e., that they run in parallel and not sequentially?
Here is my code (...
5
votes
1
answer
8k
views
Implementation of Asynchronous function call in C
I took it upon myself recently to work towards making a general-purpose Translator to automatically translate js programs into C, but I got stuck when thinking of asynchronous behaviour. Using ANSI / ...
5
votes
6
answers
8k
views
Benchmark of asynchronous code
Asynchronous programming seems to be getting quite popular these days. One of the most quoted advantages is performance gain from removing operations that block threads. But I also saw people saying ...
5
votes
3
answers
5k
views
Which layer does async code belong?
I am developing an application that consumes data from an external service. The application is being implemented following a typical layered architecture with UI, Presentation, Domain and Data layers....
5
votes
3
answers
2k
views
Providing a non-blocking IO API in a C library
I am working on a C library (SlipRock) for interprocess communication.
The library currently exposes a simple, blocking API. This is easy to use, makes misuse (relatively) difficult (this is C after ...
5
votes
1
answer
3k
views
Is there use case for implementing a callback if a future is returned?
If I have function which returns a future, is there any reason to also include a callback where the callback is simply called right before the future completes?
The only advantage I can think of ...
5
votes
1
answer
3k
views
C# async/await: Pedantry vs. the Debugger
I'm playing around with async and await, and they seem pretty intuitive, but some of the things I'm reading about these keywords doesn't make sense to me. In fact, some of it seems to me to be flat-...
5
votes
1
answer
2k
views
Implementing both Sync and Async clients with DRY
I'm developing a client library. I'd like to provide both Sync and Async interfaces to endpoints on a server. They would be rather easy to implement as completely separate entities, but I would like ...
5
votes
2
answers
346
views
Design of asynchronous component
I'm trying to design an asynchronous component. Requirements on this component are :
Component might receive events at any point in time
Component might start a long-running operation and wait for its ...
5
votes
1
answer
431
views
What are the benefits of Android way of "saving memory" - explicitly passing Context objects everywhere?
Turned out, this question is not easy to formulate for me, but let's try.
In Android, pretty much any UI object depends on a Context, and has defined lifetime. Android can also destroy and recreate UI ...
4
votes
6
answers
6k
views
Is it possible to half-way synchronize javascript functions that include async calls?
I am wondering if there exists a way to half way synchronize javascript functions, where data is requested on the fly. I don't want to make it purely blocking (which I guess is impossible), I just ...
4
votes
3
answers
2k
views
Not await an asynchronous method because it is like an endless loop - good practice?
I inherited a piece of software. This program is connected to an external hardware, which is a measurement device. Every 100 milliseconds, a value is read from this device and displayed to the user. ...
4
votes
2
answers
3k
views
Combining asynchronous and synchronous programming
I've got trouble wrapping my head around a certain problem:
In my data-flow app (a visual editor), I have both autonomous objects which communicate though ports via unordered simultaneous messages ...
4
votes
1
answer
423
views
Could the async keyword be eliminated in a new programming language?
This post implies that the creators of Rust had to add the "async" keyword to make the async/await functionality backward compatible.
Why do we need the async keyword?
In a new language, ...
4
votes
2
answers
5k
views
Is it okay for async function to update a common object
I have a couple of functions, each function verifies a set of rules and updates a common object. The common object is just a container that holds a list of rules that passed or failed. I would like to ...
4
votes
1
answer
210
views
Design for avoiding concurrent calls to an interface implementation
The application I'm developing requires that some data is obtained through different channels. As this is a network process, I have decided to use async programming.
I have designed the following ...
4
votes
1
answer
25k
views
Correct usage of async/await and Task.Run()
I am developing an application that will read excel files from disk and then process tests based on the data in the files. In order to keep the user interface from locking up when loading files and ...