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
1 vote
1 answer
36 views

Client <> Query <> Subquery Bookkeeping

Context I am making a system, where different clients issue queries A query is resolved by issuing a set of subqueries I have an invalidation-worker, which gets notified when subqueries go stale ...
Stepan Parunashvili's user avatar
6 votes
1 answer
352 views

Simple, fool-proof pattern to execute tasks in parallel

Assume I have a type task_info that stores the task-specific data needed to execute the task. A std::vector of those is built ...
Bolpat's user avatar
  • 163
3 votes
2 answers
201 views

atomic spinlock mutex class

This here is the follow-up to this question. I was recommended to implement a Lockable type (similar to std::mutex) that can work with ...
digito_evo's user avatar
0 votes
1 answer
81 views

Lock-free implementation of getAndUpdate() using atomic CAS (Compare-And-Swap) operation

We have the following class written in Kotlin Native with the new Memory Manager (which doesn't require to freeze objects): ...
Idolon's user avatar
  • 101
2 votes
1 answer
128 views

C++20 simple RwSeqLock

I recently discovered the atomic wait/notify mechanism in C++20 and wrote this readers-writer lock in the style of Linux kernel Seqlock. Writes have to be inside a lock/unlock, while reads are ...
MDH's user avatar
  • 23
1 vote
0 answers
90 views

Concurrently write results to SQLite database

The goal is to run a function compute in parallel on many inputs (10**6 in total, say) and store the results. Each call to ...
ga325's user avatar
  • 11
0 votes
1 answer
58 views

Delayed, concurrent event stack in Java - follow-up

I have slightly refactored the Delayed, concurrent event stack in Java. Now it looks like this: DelayedEventStack.java ...
coderodde's user avatar
  • 26.7k
0 votes
1 answer
110 views

A producer (mapper) and consumer (reducer) problem with concurrency in go with race conditions

Link to go playground https://go.dev/play/p/ctQDpDW6pui This code has been based on suggestions and conversations in this thread here Architecture: A read method creates a channel shared with ...
JavaDeveloper's user avatar
0 votes
3 answers
191 views

Delayed, concurrent event stack in Java

(See the next iteration: Delayed, concurrent event stack in Java - follow-up ) Motivation I was confronted with a task of having "message events" for a GUI program. The use case is as ...
coderodde's user avatar
  • 26.7k
2 votes
1 answer
106 views

Distributed lock service implementation in Golang

I have multiple E2E tests (written in Java) which share login details, each test during runtime will query the locker API for login details which is running on its own dedicated server. Below is my ...
Pawan Kumar's user avatar
2 votes
1 answer
99 views

Thread Pool Class

I have a thread_pool class, that mimics std::thread. (I would have liked std to have a pool, but alas that is not the case.) thread_pool.h ...
rioki's user avatar
  • 452
4 votes
1 answer
277 views

Thread Safe Queue

I have a thread safe queue in my library c9y. It is generally used as a task queue in the task_pool class, but in can be used for any producer / consumer problem. queue.h ...
rioki's user avatar
  • 452
1 vote
0 answers
100 views

Golang HTTPS certificate expiry checking CLI tool (UPDATED)

I previously submitted this CLI tool to this site for review and have made changes based on comments by the reviewer. I have refactored the code, fixed a bug (the tool will no longer output ...
preetpalS's user avatar
3 votes
1 answer
93 views

A mutex that can detect certain types of programming error

This mutex prevents concurrent access to a target resource. One key requirement is the ability to be acquired in a (scheduler) thread and released in a different (worker) thread. Unfortunately this ...
Raffaele's user avatar
  • 131
4 votes
1 answer
238 views

Golang HTTPS certificate expiry checking CLI tool

I am a beginner at using Golang, I would like advice about the following program. It is a CLI tool that can check the expiration dates of HTTPS certificates concurrently. I have only used the standard ...
preetpalS's user avatar
2 votes
1 answer
203 views

Sender/Receiver threads using std::unique_lock and std::condition_variable

The code below is a sender/receiver setup in C++ where the sender is in one thread, the receiver is in another, and the data being sent/received is "shared" (global). The code uses the ...
tarstevs's user avatar
1 vote
1 answer
37 views

Bulk recompiling edits to files by running external processes with a pool of 4 workers using asyncio

I am bulk recompiling edits to a c-like language which uses an external compiler.exe. The compiler takes the file paths as arguments and does the processing, nothing needs to be synchronized simply ...
0xKate's user avatar
  • 521
4 votes
1 answer
101 views

Approximate concurrent counter in Rust

I am reading chapter 29 of OS: the three easy pieces, which is about concurrent data structures. The first example these is an approximate counter. This data structure increments numbers by using a ...
ybjeon01's user avatar
2 votes
2 answers
54 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
  • 23
2 votes
2 answers
68 views

Threadsafe LRU Cache

Trying to design a threadsafe lru cache using a reentrant lock. Currently I don't like the tryLock in a loop approach. Any inputs on making it more optimal in terms of concurrency? ...
DntFrgtDSemiCln's user avatar
4 votes
1 answer
93 views

Launching two goroutines in parallel and returning result of the first finished

Real case: I need to retrieve data from a web service (main process), but in case that web service is taking too long, I retrieve the data from the cache (that data might be older) in a parallel ...
Andrey's user avatar
  • 141
2 votes
2 answers
351 views

Golang implementation of dining philosophers variant

I would like to implement a variant of the classical dining philosophers problem which has the definition as: Implement the dining philosopher’s problem with the following constraints/modifications. ...
Vincent Wen's user avatar
1 vote
0 answers
63 views

Set up pub/sub service as part of web app in Go

I have a web application that I'm writing in Go, using the Iris package. This app needs to listen to Azure Service Bus for messages, and take action when they come in. This is my first time writing ...
Kevin Whitaker's user avatar
0 votes
0 answers
54 views

Java use of CompletableFuture with supply async

Can someone review whether this code I have written makes sense? playing around with completableFutures i have a DAO implementation which should return a ...
r4bb1t's user avatar
  • 299
0 votes
0 answers
79 views

Go efficiently retrieve and process large volume of AWS s3 objects

Like the title says, code below tries to efficiently grab and handle a large number (1m+) of objects from an aws s3 bucket. Right now on a 10gb lambda function it can handle ~2m objects in ~10s End ...
Coupcoup's user avatar
  • 1,057
1 vote
0 answers
89 views

Converting future.get() to CompletionStage.whenComplete()?

I currently have some code in Java which looks something like this, but I want to refactor this. ...
r4bb1t's user avatar
  • 299
4 votes
1 answer
90 views

Task executor thread pool

Despite my experience with Java, I am not well-versed with concurrency. I wrote this thread pool that has a queue of tasks. Please ignore any signature choices, such as overuse of ...
Oliver's user avatar
  • 63
0 votes
0 answers
51 views

Framewise Full-Reference Image Quality Assessment (PSNR and SSIM) for Two Videos in Matlab

Besides the case of No Reference Image Quality Assessment for Video. I am attempting to implement a code snippet for calculating framewise Full-Reference Image Quality Assessment (FR-IQA) (PSNR and ...
JimmyHu's user avatar
  • 3,830
2 votes
1 answer
1k 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 ...
Developer Paul's user avatar
3 votes
1 answer
211 views

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 ...
AndyP's user avatar
  • 229
1 vote
0 answers
188 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 ...
Dhruv Sawhney's user avatar
3 votes
1 answer
166 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 ...
CaptainCodeman's user avatar
2 votes
1 answer
201 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 ...
AndyP's user avatar
  • 229
4 votes
2 answers
737 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 ...
Developer Paul's user avatar
2 votes
1 answer
157 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 ...
zysaaa's user avatar
  • 121
1 vote
1 answer
132 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 ...
emrepun's user avatar
  • 165
2 votes
1 answer
1k 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 ...
Primrose's user avatar
2 votes
2 answers
523 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
  • 609
2 votes
0 answers
138 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 ...
CageFury's user avatar
7 votes
3 answers
860 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 ...
Primrose's user avatar
2 votes
0 answers
436 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, ...
Julius's user avatar
  • 171
3 votes
0 answers
116 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 ...
JimmyHu's user avatar
  • 3,830
5 votes
2 answers
2k 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 ...
Developer Paul's user avatar
3 votes
1 answer
105 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 ...
morgwai's user avatar
  • 151
4 votes
1 answer
2k views

Debounce and throttle tasks using Swift Concurrency

There are many debouncer and throttle implementations created using Grand Central Dispatch, and even one built into Combine. I ...
TruMan1's user avatar
  • 123
3 votes
2 answers
294 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 ...
noes's user avatar
  • 43
1 vote
1 answer
180 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 ...
noes's user avatar
  • 43
4 votes
2 answers
645 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 ...
TheWerefox's user avatar
3 votes
1 answer
198 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 ...
clartaq's user avatar
  • 257
1 vote
1 answer
123 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: ...
morgwai's user avatar
  • 151

1
2 3 4 5
10