Skip to main content

Questions tagged [asynchronous-programming]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
141 views

How can I code synchronous programs in Node?

I'm a career programmer, very comfortable writing programs in Python, and recently started learning Node. I understand the asynchronous features are useful in many situations, but when I debug my code,...
SupaCowaFraja's user avatar
1 vote
5 answers
210 views

Purpose of async/await in web servers when stuck with legacy I/O

A couple days ago I asked about the Purpose of async/await in web servers, and got in-depth answers explaining how in fully asynchronous code, it frees up the CPU completely while also releasing the ...
Medinoc's user avatar
  • 375
23 votes
4 answers
8k 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 ...
Medinoc's user avatar
  • 375
0 votes
1 answer
110 views

In Java's Fork/Join is the operation for combining results limited to addition?

As I understand it, the join() method merge/composes/combines the results from all subtasks. A simple example I saw was summing the numbers from 1 to N and the subtasks would simply sum a range of ...
releseabe's user avatar
  • 539
1 vote
0 answers
125 views

How to structure your Python code with asynchronous and synchronous parts

I have a Python FastAPI server application which naturally guides you towards the asynchronous paradigm. For legacy reasons, I have to support two backends, one which is purely synchronous and one ...
user3058865's user avatar
1 vote
1 answer
108 views

Return function after kicking off background process

I have a process in golang that I want to kickoff through a RPC call but then have the function return early whilst the process continues in the background. Specifically it’s just a basic db transfer ...
Person1's user avatar
  • 21
3 votes
3 answers
410 views

What is the best way to retain a local object which is performing an asynchronous task?

My problem is the following: inside a method I'm creating an object like this: MyObject* myObject = [MyObject new]; Then I want it to perform an asynchronous task like this: [myObject ...
Andrey Chernukha's user avatar
0 votes
0 answers
47 views

How to handle multi-region writes for a joint user registration?

UserA and UserB are signing up for some joint service together. They both have to independently agree to T&Cs before sign-up is complete. Once complete they both receive an email to sign-in. A 1 ...
mockitodorito's user avatar
1 vote
0 answers
218 views

If you run a function in a different thread, but you wait for it to finish in your main thread, is that function asynchronous?

Backstory Probably a stupid question, but I just have a sneaking suspicion that "asynchronous" is the wrong terminology to us for naming my template function here: template <class T> ...
Anon's user avatar
  • 3,613
0 votes
1 answer
101 views

How are asynchoronous problems handled with imperative programming?

Context To level set, I've been working with OOP and FP for my whole career, so my experience with the imperative paradigm is limited. The team I joined is made up of very senior (20+ years xp) ...
Pete's user avatar
  • 1,257
3 votes
3 answers
5k views

Synchronous vs Asynchronous Event Driven Architecture

I have been searching extensively about the difference between synchronous and asynchronous patterns and how this relates to event driven architecture. On its face it is quite obvious, I simply ...
Frankster's user avatar
  • 169
-2 votes
1 answer
136 views

What is a right way to handle requests?

A social network has API, but also it has some limitations like the amount of requests that can be done in one second (let's say API will give an error, if it accepts more than 3 requests per second) ...
Roy King's user avatar
2 votes
3 answers
515 views

Is calling a completion handler synchronously an anti-pattern?

I have a function that performs a task which can either be performed immediately and without any blocking or it can only be performed after some delay. The caller of that function shouldn't need to ...
Mecki's user avatar
  • 2,350
10 votes
8 answers
3k 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 ...
Incomputable's user avatar
4 votes
1 answer
395 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, ...
phil-daniels's user avatar
-4 votes
1 answer
330 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 ...
Startec's user avatar
  • 157
-2 votes
2 answers
354 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?
spencerbug's user avatar
2 votes
3 answers
2k 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 ...
takasugi's user avatar
  • 293
-3 votes
1 answer
188 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 ...
phil294's user avatar
  • 179
0 votes
3 answers
151 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 ...
Elmore's user avatar
  • 115
-4 votes
3 answers
248 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, ...
pnatk's user avatar
  • 133
-1 votes
3 answers
668 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 ...
Lance's user avatar
  • 2,615
0 votes
2 answers
393 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 ...
Soner from The Ottoman Empire's user avatar
0 votes
1 answer
302 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 ...
hadamard's user avatar
  • 140
0 votes
1 answer
365 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 ...
Rohit's user avatar
  • 109
2 votes
1 answer
632 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 ...
The_Sympathizer's user avatar
-3 votes
1 answer
207 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 ...
Vivek Joshy's user avatar
3 votes
1 answer
316 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 ...
typicallearner's user avatar
-1 votes
1 answer
393 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 ...
Christian Vincenzo Traina's user avatar
1 vote
1 answer
348 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 ...
Patrick's user avatar
  • 571
0 votes
1 answer
222 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(...
Evan La Fontaine's user avatar
1 vote
1 answer
318 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 ...
detly's user avatar
  • 1,605
0 votes
1 answer
229 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 ...
Omegastick's user avatar
1 vote
1 answer
89 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, ...
mmseng's user avatar
  • 121
1 vote
1 answer
726 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 ...
Hyggenbodden's user avatar
3 votes
1 answer
9k 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 ...
nicktheone's user avatar
0 votes
2 answers
148 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 ...
EnterPassword's user avatar
4 votes
1 answer
702 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, ...
user26270's user avatar
  • 149
5 votes
1 answer
1k 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 ...
Felix's user avatar
  • 377
-1 votes
2 answers
92 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 ...
Guy's user avatar
  • 117
5 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,...
Liastre's user avatar
  • 171
2 votes
2 answers
737 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. ...
ArenaLor's user avatar
  • 129
1 vote
0 answers
40 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 (...
Blue's user avatar
  • 89
2 votes
2 answers
145 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 ...
Dan Monego's user avatar
6 votes
3 answers
4k 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. ...
spirc's user avatar
  • 280
0 votes
1 answer
167 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 ...
BipinR's user avatar
  • 163
0 votes
1 answer
468 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 ...
prmph's user avatar
  • 111
0 votes
1 answer
248 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 ...
fweigl's user avatar
  • 195
1 vote
2 answers
348 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 ...
IMB's user avatar
  • 343
13 votes
1 answer
8k 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'...
Kayaman's user avatar
  • 1,960