Questions tagged [concurrency]

In computer science, concurrency is a property of systems in which multiple computations can be performed in overlapping time periods. The computations may be executing on multiple cores in the same chip, preemptively time-shared threads on the same processor, or executed on physically separated processors.

Filter by
Sorted by
Tagged with
2 votes
1 answer
39 views

C++20 Multi-queue Thread Pool with Work Stealing

This is a follow up to my previous post which also follows up on my first post regarding my thread pool implementation. I have since made some further changes and attempted to improve performance with ...
user avatar
1 vote
0 answers
86 views
+100

Golang function that reads S3 files and populates maps with strings as keys

I have a below read function which is called by multiple go routines to read s3 files and it populates two concurrent map as ...
user avatar
  • 169
1 vote
0 answers
69 views

What’s the correct usage of volatile keyword in this Concurrent dictionary implementation?

Can I get some guidance around the usage of volatile keyword and design of the existing concurrent dictionary implementation, please. Here are a few design ...
user avatar
3 votes
1 answer
51 views

Lock-free, thread-safe trie container

This is a Trie data structure for mapping strings to integers or pointers in O(n) time. Based on the idea that we never delete anything from the container, we can perform concurrent read/write ...
user avatar
1 vote
1 answer
92 views

Read bunch of files in parallel and populate concurrent map

I am trying to read bunch of S3 parquet files in parallel from a S3 bucket. After reading all these files, I am populating my products and ...
user avatar
  • 169
4 votes
2 answers
132 views

C++20 Single Queue Thread Pool

This is a follow up to my previous post. I've made a number of improvements to the thread pool and corrected some bugs as well. The most up to date version of the code is available on my Github. I ...
user avatar
2 votes
1 answer
75 views

DelayQueue in Go

I tried to use Go to write a DelayQueue. I referred to the implementation in Java. So the general logic is to have a minimum heap, then try to fetch the top element ...
user avatar
  • 121
1 vote
1 answer
64 views

Bank account concurrency problem Swift

I tried to implement a simple BankAccount class to practice providing a solution to the common Bank Account transaction data race problem. Reference to a description of such a problem can be found ...
user avatar
  • 165
2 votes
1 answer
77 views

C++14 Lock-free Multi-producer, Multi-Consumer Queue

Introduction This is a follow-up to a previous question of mine, where I presented another queue of the same type to get some feedback on it. Some people pointed out some fundamental errors I had ...
user avatar
3 votes
2 answers
226 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.: ...
user avatar
  • 601
2 votes
0 answers
66 views

Parallelized Web Crawler

Exercise is here: https://go.dev/tour/concurrency/10 Prompt: In this exercise you'll use Go's concurrency features to parallelize a web crawler. Modify the Crawl function to fetch URLs in parallel ...
user avatar
0 votes
0 answers
32 views

Should I replace this request queue?

I just found myself hacking around the limitations of a backend that aborts highly concurrent transactions by queueing the requests using Solution A. I don't like this solution very much, and have a ...
user avatar
7 votes
3 answers
314 views

Lock-free multi-producer / multi-consumer queue in C++

I've been working on a lockless multi-producer, multi-consumer queue in an effort to learn as much as I can about concurrency, without the use of mutual exclusion. The queue uses a bounded ring buffer ...
user avatar
2 votes
0 answers
186 views

Parallel Breadth First Traversal in Rust

Overview I have been writing my own graph API for Rust and one thorny problem I wished to tackle was a parallel breadth first traversal of the graph. The API itself will have different graph flavours, ...
user avatar
  • 171
0 votes
0 answers
36 views

await for multiple timed blocking operations

Inspired by SO questions (1, 2) about joining multiple threads with timeout, I've created a small utility to await for any type of timed blocking operations (like ...
user avatar
  • 141
3 votes
0 answers
72 views

Order guaranteed recursive_transform template function implementation with execution policy in C++

This is a follow-up question for A recursive_transform Template Function with Execution Policy, A recursive_transform Template Function Implementation with std::invocable Concept and Execution Policy ...
user avatar
  • 3,302
5 votes
2 answers
848 views

C++20 Thread Pool

I've implemented a thread pool using C++20. I'm fairly new to concurrently/multi-threaded programming and wanted to work on a project that I could learn from while also getting to know some of the new ...
user avatar
2 votes
1 answer
65 views

synchronized access to HttpSession attribute vs static ConcurrentMap with HttpSessionListener

As a part of library implementing websocket Guice scopes I need to maintain an object related to each HttpSession called ...
user avatar
  • 141
3 votes
2 answers
125 views

C++11 revised `std::latch` implementation

This question follows up on this question. After turning the while-loop into a conditional wait using std::condition_variable, I ...
user avatar
  • 43
1 vote
1 answer
75 views

Implementation of a latch

As an exercise to learn more about multi-threading and atomic operations work in C++, I decided to implement a latch class in C++11 loosely based off of std::latch ...
user avatar
  • 43
4 votes
2 answers
199 views

2 Threads taking turns printing the alphabet

I am supposed to write code for an assignment. The goal is to make 2 threads (which are objects of a class that implements runnable) take turns printing the alphabet. One of them prints upper case ...
user avatar
2 votes
0 answers
88 views

Obtaining intermediate results from a continuously running background thread in Java/JavaFX

This is a question about Java/JavaFX concurrency. Specifically, how can the UI request intermediate data from a thread running in an infinite loop. I have a simulation program in Java and JavaFX. The ...
user avatar
  • 195
1 vote
1 answer
83 views

pointer jumping on a GPU using Aparapi

Classic pointer jumping algorithm summarizing values from an array adapted to run on a GPU instead of a PRAM. Read about openCL and Aparapi yesterday for the first time, so this is my first trial: ...
user avatar
  • 141
2 votes
1 answer
77 views

golang http.Client wrapper with rate and concurrency limiting

My goal is to safely consume an API without getting 429 Too Many Requests error, activating DDoS protection or going over system limit of maximum open file ...
user avatar
0 votes
0 answers
72 views

Is my non-blocking collection actually thread-safe?

I've implemented this out of curiosity, and I'd like to know if I've implemented everything correctly, and/or see if anyone has suggestions. This caches some metadata for a game, so: Infrequent ...
user avatar
1 vote
0 answers
50 views

"streaming" messages to a broker from a batch-like source (eg sql database), optionally acknowledge back to the source

I am writing library code to help other developers send messages to a pub-sub event broker. In many cases, the message source will not be "stream-like". Specifically, most messages are ...
user avatar
  • 111
2 votes
1 answer
124 views

Correct synchronization of reads and writes to ConcurrentHashMap and ConcurrentLinkedQueue

I am writing a web application (Servlets, JDBC, no Spring - for learning purposes) that accepts orders from customers, while registered couriers can choose which one of these orders they want to ...
user avatar
  • 21
2 votes
0 answers
36 views

Rust program to create mail.tm accounts

I have created a rust program to create https://mail.tm accounts, but I think there are things I could have done better. Are there things I can do to improve performance? Are there any unnecessary ...
user avatar
1 vote
0 answers
412 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 ...
user avatar
2 votes
2 answers
263 views

Write deduplicated 9-digit numbers from concurrent clients to a log

Problem Statement: Write a server (“Application”) in Java that opens a socket and restricts input to at most 5 concurrent clients. Clients will connect to the Application and write any number of 9 ...
user avatar
4 votes
0 answers
316 views

PyQt load images in background process

I am building an application that needs to load 100-200 images (really only limited by performance) and display them to the user in a sort of gallery. A good analogy would simply be Google Images. In ...
user avatar
  • 261
4 votes
1 answer
86 views

Intersect channels in Go

I have a simple golang app in which I have two background tasks that produce data,each of them use it's own channel to signal it produced another unit of data. I have a single consumer that needs the ...
user avatar
3 votes
2 answers
138 views

Generic concurrent bounded buffer in C

I just implemented a generic concurrent queue in C, and I'd like some feedback on my implementation, as well as the logic in handling generic data and concurrency. buffer.h ...
user avatar
2 votes
0 answers
168 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 ...
user avatar
4 votes
1 answer
122 views

A tiny threads pool in C

I'm a newbie in C, and currently following Stanford CS107 - Programming Paradigms. For assignment 6, I find it'd be better to isolate the threads management from the service logic. The following code ...
user avatar
  • 205
4 votes
2 answers
497 views

Single Producer Single Consumer lockless ring buffer implementation

I am writing a simple ring buffer for my own education. Below is a crack at a strategy described in http://www.cse.cuhk.edu.hk/~pclee/www/pubs/ancs09poster.pdf : Producer and Consumer keep local ...
user avatar
  • 49
1 vote
0 answers
42 views

Parallelizing identical long-running tasks with Go channels

I have written a program in Go to compute the discrete logarithm mod primes (find \$x\$ such that \$h=g^x\mod p\$), and the algorithm I am using can be easily parallelized. Essentially, I am trying to ...
user avatar
  • 123
2 votes
1 answer
100 views

Barging lock in Java

I found myself in need of a lock that allows my server to barge the write lock that might be acquired by my users. It would never interrupt them, but it would jump the line so the next time the write ...
user avatar
  • 650
2 votes
1 answer
504 views

Parallelized web crawler using goroutines and channels

As part of the "a tour of Go" section on golang.org, I was trying to make a (formerly singlethreaded) web crawler parallelized using goroutines. I got it working but it doesn't seem to "...
user avatar
  • 8,392
2 votes
1 answer
240 views

Thread-safe LFU Cache

I am trying to implement a thread-safe LFU cache algorithm, please review my code and would really appreciate some criticism or suggestion. (on naming, design, data structures used, anything) Some ...
user avatar
  • 31
1 vote
1 answer
476 views

Thread-safe LRU Cache Implementation in Java

I am trying to implement a thread-safe LRU cache algorithm, please review my code and would really appreciate some criticism or suggestion. Some assumptions: capacity will be larger than 0 Some ...
user avatar
  • 31
4 votes
1 answer
69 views

SHA256 password cracker - v2 with concurrency

I have updated my previous code with the suggestions. I have also implemented concurrency to speed up the results. I'd be interested for comments on a more efficient use on concurrency / parallel ...
user avatar
  • 2,033
1 vote
1 answer
660 views

SO golang example with infinite for / channel workers

I whipped this up as an example of how infinite loops can often be used to great effect in golang, and also to discuss closing channels and worker communications. It was strictly off the cuff, but I ...
user avatar
3 votes
1 answer
73 views

Waiting for goroutines to finish

I have a program that starts a bunch of goroutines, feeds them data and when there is no more data, waits for the goroutines to finish. I use sync.WaitGroup. I am unsure if I am using correctly, in an ...
user avatar
4 votes
1 answer
136 views

Speeding up I/O bound python program

I have the following program. I have 90 million domain names split between 87 files. I need to resolve the IP of all. Right now I feel like this is super slow. ...
user avatar
  • 143
4 votes
1 answer
70 views

A Concurrent Tree implementation with consistent snapshot capability

I have a tree in my application from which I need to periodically take a snapshot. I've been using locks so far, but after running into a few deadlock issues I decided to create a lock-free ...
user avatar
6 votes
1 answer
170 views

Concurrent Web Crawler

Description As an exercise of learning go concurrency patterns, I decided too build a concurrent web crawler. I made use of the argparse module I put up for review a while back. I'm looking for ...
user avatar
  • 11.4k
2 votes
1 answer
73 views

Concurrent dependant routines in a gui application

The idea is that, in my application I have 5 routines named long_process_1, long_process_2, ...
user avatar
2 votes
1 answer
66 views

Keep reading user keyboard input if available, while echoing back the latest available

On StackOverflow I have asked a question a few minutes ago, but then by trying a bit more, I found the answer myself, and I'm posting the resulting working code here for review. What the code does, is ...
user avatar
  • 497
4 votes
0 answers
90 views

Game of Life, thread per cell

In an effort to learn Java's support for concurrency I solved a self-imposed exercise to write a Game of Life simulator in Java, running a separate thread for each cell. Here is my code: ...
user avatar
  • 571

1
2 3 4 5
9