Questions tagged [asynchronous]

Asynchronous programming is simply allowing some portions of code to be executed on separate threads. It makes your applications perform better, be more responsive, and use the resources of the system they are running on to the fullest extent.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
21 views

Running a spawn_local task inside LocalSet

I'm having issues with the use of tokio::task::spawn_local and tokio::task::LocalSet. Examples I see on rust docs show a single ...
corsel's user avatar
  • 99
1 vote
0 answers
37 views

Debounced inotify watcher in rust

Here is a tiny (cli) tool to run a script with the state of any of a set of watched files when one of them is opened or closed. It applies basic debouncing to handle bursty access. It was written to ...
2e0byo's user avatar
  • 321
3 votes
1 answer
61 views

C++ Readers-Writer Lock using Asio's Strands

The locking mechanism is implemented in the class RW_Lock. The saved_async_completion_handler structure is used in ...
DeltA's user avatar
  • 133
0 votes
0 answers
100 views

For loop vs If statement using conditional variable

I'm extending the sync.Pool type by limiting the amount of objects that can reside outside the pool. To achieve this I'm using ...
Bernardo1r's user avatar
7 votes
1 answer
960 views

C++: algorithm that uses fixed-size buffer of data that are produced in stream, faster than the algorithm speed

I try to implement this scenario with a producer/consumer multithread pattern and I'd like to optimize synchronization and memory model directive used. This code originates from a SO question and its ...
Oersted's user avatar
  • 299
2 votes
1 answer
62 views

Single worker, multiple async callers in different threads

My use case is this: There is a long running process that I want to ensure is only ever running at most only a single time. Multiple consumers from different threads may wait on the calculation. If ...
Aviad P.'s user avatar
  • 123
4 votes
2 answers
118 views

Get files downloaded asynchronously after double clicking on list item (C++)

The problem I am trying to solve as an exercise is as follows: I have a UI running in the main thread, specifically a list view with many items. Each item represents a file that the user can download....
M. Saintourens's user avatar
2 votes
2 answers
161 views

Code for asynchronous data stream processing with multistage pipelines

I am trying to write some code for processing streams of asynchronous data from multiple sources (Producer Nodes), process them ...
Haaput's user avatar
  • 23
0 votes
0 answers
44 views

Visualizing a mashup API in Postman

The MusicBrainz API has information about artists and music bands. 1 An example – a request for the British rock band Coldplay is: http://musicbrainz.org/ws/2/artist/cc197bad-dc9c-440d-a5b5-...
Henke's user avatar
  • 101
0 votes
0 answers
56 views

UIImageView loading from URL with cancellable task and safe to use in a UICollectionView

I am trying to make a UIImageView class / extension that can load an image from a URL. the image view should not get confused with concurrency when scrolling through a UICollectionView and the data ...
Halpo's user avatar
  • 101
0 votes
0 answers
33 views

Asynchronously building a service container in TypeScript

The compiler provides a synchronous use() method which accepts a middleware - that is a function that creates any services it wants, the ...
slepic's user avatar
  • 5,357
4 votes
1 answer
684 views

Asynchronous file writer : queue, mutex, condition variable

As we know, it is better to write to a disk in a separate thread because the bottleneck may be the disk, which is slower than the CPU (at the condition only one thread writes to the disk). So I have ...
rafoo's user avatar
  • 315
2 votes
1 answer
360 views

Tool for asynchronous IPC using pipes

Description of the code: The code provides asynchronous IPC functionality in C++ using the Boost libraries and pipes. Each process asynchronously "listens" on the read end of the pipe and ...
kasra's user avatar
  • 123
0 votes
0 answers
174 views

Asynchronous DB session in Python (used in ASGI framework such as Sanic)

I've been working with Sanic as my default web framework, but coming from Flask, I had some issue with how to handle the database connection. So I built an asynchronous wrapper around it. I've also ...
Cyril N.'s user avatar
  • 245
1 vote
1 answer
333 views

Make C++ Task class similiar to C#'s Task

I am enjoying making various programs with C++. This is my first code review request. And I hope I can get some insights or might have good advice to make my code better. I make a task class using C++...
Y.frank's user avatar
  • 29
3 votes
1 answer
265 views

SetTimeout to populate Javascript Object while a function looped AJAX requests to get data

I wrote some code that will get the name and data of a node or multiple of nodes and put them in an object (seriesData) so I can use said object for a chart (renderChart). I used setTimeout() so ...
Bewarden's user avatar
3 votes
2 answers
679 views

Wait for a callback and then using the result

I'm using Frida to run a script on a process, and I want to wait for it to send the result back to me, as a callback. My current code looks like this: ...
JJTech's user avatar
  • 79
2 votes
2 answers
61 views

Load data from database, change it asynchronously and return the new data

I have written this function to load data from the database, change it asynchronously and return the new data. It appears to work fine, but since I am new to Kotlin, I wanted to ask if this code is ok ...
Newbee's user avatar
  • 33
1 vote
0 answers
171 views

Promise in an Express app to send OTP verification e-mail

In this code I'm using nodemailer for sending otp email from my gmail account. I have also used ejs for creating html templates for emails. This code works perfectly, but I am a bit concerned about ...
Bhaskar's user avatar
  • 133
1 vote
1 answer
117 views

Using Swift Combine's .map function with external variables

I have a motionManager class which uses CMMotionManager() to send rotationRate and attitude values to a publisher in the form of a MotionValueModel. ...
Bjorn Morrhaye's user avatar
4 votes
2 answers
338 views

Game loop using Future.wait_for to check for input

I started writing this game from scratch yesterday, and I wasn't completely new to C++'s future library. I only use the ...
FLAK-ZOSO's user avatar
  • 143
0 votes
0 answers
243 views

ASP.NET Core 6 background DB logger

In an application, many actions need to be logged in the database. but this logging process should not slow down the request. So they should be done in an asynchronous queue or something. This is my ...
Parsa99's user avatar
5 votes
1 answer
343 views

Filtering an Option Result using a boolean Result in Rust

I'm trying to rewrite one of my pet projects in Rust, and when I was faced with the problem of filtering a Result<Option<T>, E> via a ...
Yalin Gunayer's user avatar
2 votes
1 answer
231 views

Java class to run CompletableFuture<T> instances in batches

This is a utility class for running CompletableFuture<T>s in batches (e.g. to avoid using too much bandwidth making HTTP requests). It seems to work, but I'm ...
William Bradley's user avatar
0 votes
1 answer
232 views

Asynchronous recursive function for generating a unique Id

The code below is my first purpose built asynchronous recursive function. It took me a while to figure out how to write the thing, and I would like a second opinion. It's part of a project for The ...
ablueblaze's user avatar
1 vote
0 answers
401 views

Asynchronous socket server implementation from raw sockets

I've rewritten my HTTP server several times over the past year, because I tend to encounter an issue midway through an implementation realizing I didn't abstract, decompose, or decouple certain ...
uspectaculum's user avatar
2 votes
1 answer
122 views

Javascript function which polls an async endpoint and inserts the result in a web page

I read about debounce this morning and ended up needing something similar to the concept in real life this evening to build a poll that checks whether a link I receive from an async call is ready to ...
Dozie's user avatar
  • 21
1 vote
1 answer
1k views

Collect and combine results of async calls returning completable futures in Java in a cleaner way?

I need an abstract way to implement this below functionality because in my code I have to use it in multiple places with different REST endpoints. If I ignore it will cause code duplication. Please ...
tomsheldon's user avatar
3 votes
2 answers
703 views

Blocking call to an async function

While migrating to structured concurrency it may be sometimes convenient to temporarily make a blocking call to an async function - e.g.: ...
Milos's user avatar
  • 619
0 votes
0 answers
47 views

Synchronous Lock system with asynchronous methods

I needed a way to ensure that a function called was done only one at a time. Because of how Javascript is done and with Asynchronous functions, this wasn't the case, and there could be concurrency ...
Cyril N.'s user avatar
  • 245
2 votes
1 answer
389 views

Resilient & Stable TCP Server Polling

I am looking for feedback to perfect my code developed for WPF in terms of speed, stability and resiliency. My code is supposed to handle synchronous status polling as well as asynchronous Commands to ...
Bilal Kazi's user avatar
5 votes
1 answer
574 views

Task-based TCP socket wrapper class

Recently I've been entertaining the idea of making a small encrypted chat app as a way to learn about UI, encryption and networking in C#. After some research/work, I've produced the below protocol ...
SomewhereOutInSpace's user avatar
1 vote
2 answers
352 views

group countries by language in JavaScript

I need a better implementation than the below code (O(N) Solution), I am grouping countries by language ( data ) is the countries JSON, each country could have 0, 1 .. or more language as the object ...
Odeh Abuzaid's user avatar
2 votes
0 answers
127 views

Asynchronous TCP server refactor design & not working features

I'm working on an asynchronous TCP server which is supposed to be used for a chat. I want to get a review for the TCP server part because I'm struggling to find a good design to fulfill the following ...
nop's user avatar
  • 719
0 votes
1 answer
89 views

React async useEffect with loading and error state

This is my first time trying to add clean error handling and loading notification for async requests in my project. It looks kind of bulky to me, but maybe that's because I'm inexperienced? This is ...
KGE's user avatar
  • 11
2 votes
0 answers
804 views

A reuseable reconnecting TCP socket with Asio

I'm using (non-boost) Asio 1.18.1 and C++17. Forgive the boost tag, there wasn't a more specific one. I have a async_connect_with_retry composed asynchronous ...
MHebes's user avatar
  • 143
2 votes
0 answers
70 views

Asynchronous line-based communication with an external program

As part of a larger project, I've written the following code for interacting with git-annex's addurl command in batch mode. ...
jwodder's user avatar
  • 302
2 votes
1 answer
167 views

Learning asynchronous caching by implementing one

After implementing a serial CLOCK second-chance cache in C++ without having enough rope to shoot myself in the foot, decided to dive into Javascript through NodeJs and write an asynchronous one. I ...
huseyin tugrul buyukisik's user avatar
3 votes
1 answer
131 views

Using the Decoder class in a streaming context

Am experimenting with the IAsyncEnumerable interface and PipeReader class. Have come up with the following to decode a stream of bytes into chunks of characters and am able to decode all of my test ...
Kittoes0124's user avatar
  • 1,930
2 votes
0 answers
2k views

Implement Websocket using boost::asio::beast with serialized writes

Here's a proposal implementation of websocket using boost::asio::beast that is thread-safe to parallel writes. In this example below, the ...
Zohar81's user avatar
  • 153
1 vote
1 answer
74 views

Is this good practice to declare variables freely inside async function?

example: ...
sh2a's user avatar
  • 125
3 votes
1 answer
900 views

Best way of cleaning up resources with CompletableFuture [closed]

Edit: cross-posted this question on Stackoverflow. Suppose I have a function that takes a FileInputStream, performs some operation using the file data in the ...
mperktold's user avatar
  • 133
1 vote
1 answer
175 views

My 3D to 2D graphics algorithm is being a bit slow

With my VB.Net Windows Forms application, I would like to rotate and project a 3D object. The program works so far, which is why I'm reporting here and not Stack Overflow, but it's slow. I've already ...
Daniel's user avatar
  • 219
3 votes
1 answer
142 views

Converting python code to async calls

I'm going to start out by saying this is the 1st python program I have ever written and have no real background in the language so my code is probably pretty rough. Take it easy on me! When I wrote ...
James's user avatar
  • 61
4 votes
1 answer
116 views

Async streaming of Reddit posts

roux is a Rust library that wraps the Reddit API. Neither Reddit nor roux provides a stream-like interface for obtaining the ...
Florian Brucker's user avatar
2 votes
0 answers
972 views

Are nested calls to `asyncio.gather()` dangerous?

I wrote this ~100 line script recently, where I tried out Python's asyncio library. When it comes to asynchronous programming in Python, I just have 2 days of ...
Vikas Prasad's user avatar
2 votes
0 answers
457 views

Read Data from a serial port and write to influxdb

I have a energy meter which sends the kWh count periodically every few seconds via a serial port. To store this data I write the counter value and the calculated average power of the last 10s in a ...
HaWe's user avatar
  • 53
6 votes
1 answer
4k views

Async download of files

The following code is an async beginner exploration into asynchronous file downloads, to try and improve the download time of files from a specific website. Tasks: The tasks are as follows: Visit ...
QHarr's user avatar
  • 375
2 votes
0 answers
228 views

Fixed-width non-FIFO DispatchQueue

I have implemented a custom concurrent queue on top of GCD which offers two additional pieces of functionality: Limit the maximum number of concurrently executing tasks. Give manual control over ...
Marcel Tesch's user avatar
0 votes
0 answers
65 views

Idea for writing asynchronous data processing chains easier (similar to `ReactiveX`) and its implementation

I'm writing my own library, that is for asynchronous network communication. and then, wanna write my own HTTP proxy server for load-balancing connections to backend servers with it. when I'm using <...
jay k's user avatar
  • 95

1
2 3 4 5
11