Questions tagged [asynchronous-programming]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
10
votes
8answers
836 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 ...
0
votes
0answers
22 views

React Redux chain-of-actions pattern - should I create new synchronous middleware for synchronous actions?

I am creating React Web application with Yii2 API and Redux-Saga which calls Yii2 API (asynchronously). I am stuck with one especially large and complex user action (initiated by the selection of good,...
5
votes
3answers
2k 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. ...
3
votes
1answer
237 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
1answer
66 views

Does native async implementation in languages like Python and C# Solve the "Free Lunch is Over" problem? [closed]

A while ago Herb Sutter wrote The Free Lunch Is Over: A Fundamental Turn Toward Concurrency in Software which I basically interpret to mean that, in order to improve performance, software engineers ...
0
votes
3answers
97 views

Is it better (or preferred) to initialize allocate and free structures used by a thread, "inside the thread"

Let's say we are building a threaded program in C, for example a message queue system where a thread is spawned to manage one end of the queue, and (re)connect sockets. This can roughly be set up in ...
-2
votes
2answers
139 views

Does async IO use less energy than multithreading? [closed]

Given the same application written with multi-threading and async IO, will async IO use less power on a computer?
0
votes
1answer
82 views

How can message queues improve scalability?

I have read in a DDD book that using message queues between communicating services can make the whole architecture more scalable, amazon's documentation mentions that queues provide granular ...
-3
votes
1answer
116 views

Why isn't JavaScript always async? [duplicate]

In JS, code runs single-threaded, that's why asynchronicity is necessary. I cannot use code like result = someRequest(), instead I need to give it a callback someRequest(resultCallback) or write a ...
-4
votes
3answers
189 views

Confusion with asynchronous programming

I have been reading about the concept but still it doesn't make sense to me. I want to clarify my question by giving an example. First of all, if we have task1 and task2 which have to run in sequence, ...
4
votes
2answers
702 views

Async library guidance

I'm creating a library that contains a class that exposes several Async methods: public class MyClass { public async Task<Foo> DoFooAsync() { /*...*/ } public async Task<Bar> ...
0
votes
1answer
611 views

Querying in event driven microservices

I am trying to get my head around "event driven" microservices. I understood, there are several techniques and patterns, like event notification, event sourcing, CQRS, etc that can help us to achive ...
-2
votes
3answers
141 views

What happens in terms of call stacks when 10000 setTimeouts are called?

Say we call 10000 setTimeouts, each with a random time, each with a few nested timeouts too. What happens in terms of the 1 call stack, or are there multiple call stacks? How does that work? So for ...
0
votes
2answers
176 views

Why/When do we need to call an async method from a sync method?

It is my first question here so I hope I'm not doing a mistake. I see a plethora of questions in SO that people ask "how can I call an async method from a sync method?". Given my little ...
0
votes
1answer
107 views

How do Asynchronous Webserver (FastApi, Quart etc.) handle many Requests better than synchronous Webservers

I started using Pythons async features and want to fully understand their use cases. I see webserver like FastApi or Quart which use async features. How are they working different from webservers like ...
0
votes
1answer
132 views

Is this the right way to call async and await

Hi I am new to async/await in C# . I have created a controller which is accessing result from HttpClient injected through HttpFactory. Here is my working example class MyController { private ...
31
votes
14answers
12k 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 ...
1
vote
1answer
99 views

In an MVC-patterned app, how should one build the interface between model and user interface layers to work nicely with threading?

I am wondering about this. This is a sort of follow-up to my last question here: In the MVC pattern, what has the responsibility for creating the view? because now I've run into the question of how to ...
-3
votes
1answer
199 views

How do I make items disappear based on the size of it's members?

Consider a list of items (take a list of voice channels) where each item has these attributes System::vc: List of voice channels. System::on_join(member, before, after): On the event when a member ...
2
votes
1answer
125 views

How to design asynchronous communication in microservices?

Intro Hey, my question is kind of hard to explain so I apologize in advance. Question I'm trying to implement microservices for our ecommerce and I'm having issues on how to respond to a request when ...
31
votes
2answers
8k 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 ...
2
votes
1answer
262 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 ...
-1
votes
1answer
196 views

Is async/await a good alternative for locks in JavaScript?

Yes, I know, the question title is a bit provocatory. But let me explain. I needed to execute a sequence of async tasks in JavaScript. They are async because I need them to be non-blocking, but I ...
1
vote
1answer
206 views

std::future everywhere? Why or why not? [closed]

I recently had a discussion with colleagues about the use of futures (std::future in C++) or asynchronous calls in server applications. On one hand, if you have server logic that needs to access an ...
0
votes
1answer
114 views

How to maintain SRP with a chain of async functions?

For code maintainability I understand that it is generally better to have code structured like this: void abc() { a(); b(); c(); d(); } Instead of like: void abcd() { a(); bcd(...
1
vote
1answer
160 views

What is the name of this kind of (intra-process, inter-thread, queue-based) event system?

Context Espressif's embedded development libraries for the ESP32 microcontroller contain an event system based on FreeRTOS. The event system handles connectivity, interrupts and other IO activity, but ...
44
votes
5answers
28k 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 ...
0
votes
2answers
140 views

What is the best practice for incorporating asynchronous code in this case?

Context: I'm building a popup widget. The html and css files are stored in S3. I need to get those files asynchronously and then continue with the rest of the logic. In the code below, I'm getting ...
0
votes
1answer
147 views

How do I not lose the "reactive" nature of my services, simply because one of the services isn't reactive?

I've lately been very interested in reactive microservice design with streaming and event-driven architectures. When one writes (i.e., manages) services, this paradigm works extremely well by simply ...
27
votes
3answers
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 ...
2
votes
2answers
254 views

Design tips for waiting for a user input while working on another thread

I am working on an application with multiple threads (using Qt, C++). One of this threads is designed to execute a batch of operations like reading/writing from/to files as well as creating new ones. ...
0
votes
1answer
77 views

Handling background tasks that may not be relevant when they are completed

Imagine the following pattern: you have a window with information that needs to be updated asynchronously. You launch and detach a thread to handle fetching the information, but while the information ...
1
vote
1answer
44 views

How could I optimize an AJAX-based site by avoiding unnecessary/duplicate file-reads for each AJAX call?

I'm an IT guy (read: not a professional programmer) and have made an internal monitoring webtool which allows users to search for printers on our print servers. Based on the filtering criteria given, ...
5
votes
2answers
2k 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,...
0
votes
1answer
290 views

What is the relationship between reactive programming and stream processing engines?

When would I use reactive programming libraries like RX Java and Project Reactor compared to stream processing engines such as Storm and Flink? I am aware that these concepts might not be directly ...
0
votes
1answer
3k views

How to approach a large number of multiple, parallel HttpClient requests?

I have a website which offers pages in the format of https://www.example.com/X where X is a sequential, unique number increasing by one every time a page is created by the users and never reused even ...
4
votes
1answer
382 views

Is this a good design for wrapping asynchronous API calls into a RESTful interface?

I'm working with an API that has many asynchronous calls and handlers. I'd like to extend these with a RESTful interface and endpoints in spring. I'm imagining the usual Controller and Service layers, ...
-1
votes
2answers
78 views

How to GET multiple values from a database while keeping the request asynchronous?

This is a very small-scale project that I am coding myself, so I am able to build all of the resources however I like. I've done research on this site for help on this issue and can't find anything ...
2
votes
3answers
590 views

Transitioning to asynchronous programming model

Our team is mantaining and developing a .NET web service written in C#. We have stress tested the web service's farm and we have evidence that the actual architecture doesn't scale well, as the number ...
6
votes
1answer
5k 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 ...
1
vote
0answers
32 views

Using TPL to manage hundreds of contexts

Overview of application: A chat bot that connects via IRC, using TPL. As messages come from the socket (from .ReadAsync()), they are ultimately parsed and passed to a handler within the bot itself (...
2
votes
2answers
137 views

Name of locking approach

I've seen this approach several times, both in async and multithreaded code. A counter is used to track asynchronous behavior or thread behavior - whenever a new action is started, the counter is ...
0
votes
1answer
141 views

I'm writing an application that needs to log error/ exception messages but should still continue execution if it not a fatal error

I'm writing an application that needs to log error/ exception messages but should still continue execution if the error is not a fatal error. I was thinking of making a method that returns a Task but ...
0
votes
1answer
433 views

Heroku request timeout vs Nodejs architecture

At this link (https://blog.heroku.com/timeout-quickly#how-webservers-work), I read: All webservers will work in a similar way. Any new request will go to a queue, and the server will process ...
0
votes
1answer
153 views

Should repositories always return Rx Single or Observable?

Let' assume we have an IFiltersRepository repository that provides data about a list of "filters" that are used on the search screen of an app (filter by color, by price etc). The repository has the ...
1
vote
2answers
176 views

Acceptable to use synchronous call to another microservice for time-sensitve state change?

Say there are two microservices (example is simplified) PickupRequestService: lists pick-up requests of passengers DriverService: drivers use to accept pickup requests On a completely decoupled ...
11
votes
1answer
4k 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'...
0
votes
2answers
429 views

Turn an asynchronous delegate pattern into a blocking method

I have to use a built-in API that works like this class MyAPIWrapper { func callAPI() { apiObj.delegate = self apiObj.doWork() // returns immediately, eventually calls self.delegate....
3
votes
1answer
135 views

Future/Promise objects in Controllers - Best practice - MVC [closed]

I was going through some articles related to Futures and Callables today and was thinking about the best practices when working in an MVC based environment. I was wondering, should one be creating ...
0
votes
1answer
198 views

Which message pattern should I use?

I'd like to develop a microservice architecture application that sends text messages from one communication provider to another and I'm just considering changing architecture would be best suited to ...