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
3 votes
1 answer
120 views

Using async websockets in Rust with tokio, rmp-serde and varint encoding

This is my first attempt at a real life app in Rust. I would mostly like to know if I am writing idiomatic Rust code, coming from Java and Python. I'll appreciate any pointers to improvements, though. ...
8192K's user avatar
  • 131
1 vote
0 answers
65 views

Telegram bot computing a heavy I/O task

Introduction I have a telegram bot based on aiogram framework. It does GPU intensive computations locally then user makes a request and outputs a text file after ...
Amir Suleymanov's user avatar
1 vote
0 answers
60 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
345 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
108 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
1k 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
80 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
5 votes
2 answers
137 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
419 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
69 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
4 votes
1 answer
973 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
  • 325
2 votes
1 answer
561 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
207 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
512 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
424 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
944 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
63 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
  • 43
1 vote
0 answers
209 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
2 votes
1 answer
179 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
500 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
365 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
476 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
312 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
299 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
474 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
176 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
2k 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
963 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
57 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
477 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
689 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
405 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
155 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
  • 739
0 votes
1 answer
107 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
1k 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
74 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
  • 402
2 votes
1 answer
198 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
150 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,940
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
77 views

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

example: ...
Sha'an's user avatar
  • 125
3 votes
1 answer
2k 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
184 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
157 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
119 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
1k 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
553 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
5k 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
253 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
-1 votes
0 answers
68 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
  • 83
0 votes
1 answer
1k views

Using asyncio and aiohttp in classes

To better familiarize with async requests I wrote a very simple scraper that relies on aiohttp to retrieve some basic information from the product page (product ...
anddt's user avatar
  • 195

1
2 3 4 5
11