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
5 votes
1 answer
58 views

Recur-ratively resolve dependencies and summarize all results

I've been tasked with resolving all dependencies to a project. Because it couldn't be simple (it never is, right?), the requirements include a few different dependency management tools. For a first ...
user avatar
  • 25k
1 vote
0 answers
79 views

MVC web app writing to file in a threadsafe way

This is as much a code design question as a code review. I am adding some temporary code to my website to record search terms used. For now I'm also storing a few other fields. This is an ...
user avatar
4 votes
2 answers
215 views

Task Wrappers for starting operation only if previous task has finished

I've written these two wrappers around Tasks, to help with common scenarios in our code where methods are called repeatedly, even if the previous operation hasn't completed yet. There are two common ...
user avatar
4 votes
1 answer
3k views

Blocking queue implementation with std::unique_ptr

I implemented, somewhat closely based on this implementation, a blocking queue with emphasis on filling up first. So if one producer and one consumer thread are using the queue, the producing queue ...
user avatar
  • 43
3 votes
0 answers
689 views

Implementing non-blocking Executor.map

I wanted to extend concurrent.futures.Executor to make the map method non-blocking. It seems to work fine, but I would be very ...
user avatar
  • 205
8 votes
3 answers
2k views

The dumbest (futex-based) mutex

After reading Ulrich Drepper's "Futexes are Tricky", I have written the following "dumbest mutex" in C++14 using the Linux futex primitives. This mutex is simpler ...
user avatar
  • 19.1k
3 votes
1 answer
877 views

Producer - multiple consumer implementation using futures

I've tried to implement a producer-multiple consumer pattern using futures and I was wondering should it ever deadlock, and if it should, why? I have this method ...
user avatar
  • 133
6 votes
3 answers
690 views

Delegating ExecutorService implementation requiring only an Executor

I occasionally find myself needing to run code on some arbitrary thread or pass a Runnable to some arbitrary consumer, and missing the full functionality of java.util.concurrent -- for instance, ...
user avatar
1 vote
1 answer
937 views

Polling an API endpoint with timeout using channels

I have written a simple API client for my app in Go. The client is very simple, it wraps http.Client and has some convenience methods. The one method I am trying to get some feedback on, does ...
user avatar
  • 771
0 votes
0 answers
152 views

Pause & Resume producer

Following code produces number sequentially. There will be only one such producer, However there can be many threads to pause/resume the list of sequential numbers. ...
user avatar
2 votes
1 answer
156 views

Thread-safety based on object value

I need to create thread-safety on a Web-API method, but only when two requests containing the same property value are ran simultaneously. I have created a mix of WaitHandles and a ...
user avatar
5 votes
1 answer
7k views

Java Matrix multiplication using Multithreading

I am trying to achieve matrix multiplication using the concept of concurrency and cyclic barrier. Here is the code snippet:- ...
user avatar
  • 53
3 votes
1 answer
3k views

Send multiple broadcast to multiple listeners

I want to send multiple broadcast to multiple listeners in go. I can't send data through a channel, because only one listener will get it, except for the close ...
user avatar
  • 1,862
3 votes
0 answers
175 views

Concurrent AWS S3 copying of images listed in MySQL

I created the following one off script and it did the task quite well (1000s of requests / second with low CPU usage - outperformed the previous python script in every aspect). But I am wondering if ...
user avatar
3 votes
1 answer
50 views

Call third parties in parallel

I am trying to speed up some reporting on all employees but I am having difficulty determining where the "proper" place to parallelize my tasks. In order, this is what my code is currently doing. Ask ...
user avatar
  • 133
5 votes
1 answer
5k views

Thread-Safe Task Queue Implementation

Purpose: This class exists to ensure actions created from other threads are executed in a synchronous manner. Additionally, it provides functionality to add actions that run after a delay. Code: (...
user avatar
  • 151
9 votes
2 answers
1k views

C++11 Blocking connection pool with auto release

Relatively new to C++. Please help me understand the potential issues with the following blocking object pool. ...
user avatar
  • 189
4 votes
1 answer
128 views

Link checker using Go channels

I've started to learn Golang and channels in it. I decided to write simple application - recursive link checker. Given some URL it tries to retrieve pages, parses them and goes deeper. Here's a code ...
user avatar
6 votes
3 answers
2k views

Concurrently reading a Map while a single background thread regularly modifies it

I have a class in which I am populating a map liveSocketsByDatacenter from a single background thread every 30 seconds inside ...
user avatar
2 votes
0 answers
616 views

Producer / consumer pattern with limits on .NET

For a project that I'm developing, I need to implement the producer/consumer pattern, but the quantity of consumers cannot be higher than some number (say 40). I created a concept project on GitHub ...
user avatar
1 vote
1 answer
94 views

canonical pattern for transactional library state manipulation

In golang I am finding that there is a definite pressure in the language itself and built-in libraries to do things in a canonical way. Please can someone critically look at these two ways I am ...
user avatar
4 votes
0 answers
64 views

Fast lock implementation using pipes only

For fun I wanted to create a lock implementation that was about as fast as one using futexes but that used used pipes instead and that queues waiters in user space instead of in-kernel. For the queue ...
user avatar
1 vote
2 answers
89 views

Simplified LogService (from concurrency in practice) with shutdown feature

Brian Goetz provided following code of LogService with shutdown feature: ...
user avatar
2 votes
1 answer
99 views

Repeat operation if signal is received

I have a data synchronisation operation that is observing a database. This is a fairly key piece of code for the system, so I want to make sure I handle the concurrency correctly. The problem The ...
user avatar
  • 161
3 votes
1 answer
420 views

Concurrency and locking in a chat server

I've never done concurrent programming before, but I've written one using go channels and RWMutex, but I'm not sure if my approach is idiomatic. I feel like it could all use channels (Maybe). The ...
user avatar
  • 204
3 votes
1 answer
2k views

JUnit assertion for concurrency test

I'm learning Java concurrency by a TDD approach. Therefore I wrote a basic test case in JUnit to test the behaviour / expected results of 2 threads. I'm looking for feedback for this code. In ...
user avatar
0 votes
1 answer
1k views

Turn a non-blocking concurrent queue into a blocking concurrent queue

Microsoft Visual Studio offers a non-blocking concurrent queue class, concurrency::concurrent_queue, based on Intel's TBB. I am using this as a base for a blocking ...
user avatar
  • 293
0 votes
2 answers
3k views

Concurrent Stack with blocking and non-blocking methods

I wrote it this just for learning. Is there holes at this code? ...
user avatar
1 vote
1 answer
584 views

Concurrent blocking stack

I just want to train before interview. I googled concurrency interview questions and one of the question was write concurrent ready stack. ...
user avatar
2 votes
2 answers
4k views

Running multiple producer and single consumer in a multithread environment

I have a below class in which add method will be called by multiple threads to populate messageByChannelReference concurrent ...
user avatar
3 votes
1 answer
348 views

Parallel brute-force solution for Project Euler 4 (Largest palindrome product)

The pe4Concurrent.go file given below is my first attempt at writing a concurrent programme, pe4.go is a non-concurrent implementation of the same algorithm for comparison purposes. The algorithm ...
user avatar
  • 133
3 votes
0 answers
69 views

Creating an observable stream of clicks and converting it to an iterator

Problem 1 StratifiedJS allows people to cleanly create observable streams using the Stream class from sjs:sequence: ...
user avatar
  • 131
0 votes
1 answer
266 views

Caching wrapper for digest computation

I need to review this code: ...
user avatar
2 votes
1 answer
298 views

Receiving messages from TCP socket and processing them

I would like someone to look at my class for reading messages from a network socket. In short, the whole app should behave like a regular ping command with some additional functionalities. The point ...
user avatar
  • 43
2 votes
0 answers
408 views

Concurrent ObjectPool using ConcurrentLinkedQueue

Main ObjectPool Class: It uses atomic operations and a concurrent linked queue to achieve the best performance compared to Apache commons pool. I want to make sure there are no concurrency issues even ...
user avatar
1 vote
0 answers
333 views

Queue that permits at most X simultaneous operations

I ran into this once (permits=N) and then again today (permits =1) where I only want 1 to N operations running simultaneously. One example comes from firing into a state machine (the permit=1 example)...
user avatar
5 votes
0 answers
171 views

Concurrent Queue using Ada SPARK with the Ravenscar profile

See here: https://gitlab.com/linted/linted/blob/162b5e9fba53a90b3c6d78e214776e069c3c722b/src/ada-core/src/linted-queues.adb The code implements a concurrent queue. It can't allocate memory or use ...
user avatar
7 votes
1 answer
7k views

RabbitMQ wrapper to work in a concurrent environment

I'm developing a common library for my organisation that will be used across different services by different teams. The library is a simple wrapper for RabbitMQ. Some services will only be producers, ...
user avatar
2 votes
0 answers
490 views

RCU in C++11 using std::shared_ptr and a little more

Here's some code I wrote to solve a problem at the server I'm working on. Is this valid? I've tested it, and it works, but I would like some opinions on this. It's basically a ...
user avatar
6 votes
1 answer
773 views

Consumer/Producer (Concurrency) - Exception Handling

I have a circular buffer (array/first in first out), a consumer and a producer. A producer puts random numbers into the array, and a consumer takes the first number and checks if it is relative prime. ...
user avatar
  • 61
2 votes
1 answer
128 views

Time out or get a result when available

I have a system that can put and get messages from a messaging middleware (JMS), which is asynchronous. I need to provide an API that allows synchronous call, as in, when the API/method is called, it ...
user avatar
  • 123
3 votes
2 answers
2k views

Enforce execution order with collections of CompleteableFuture's

I receive a message that contains a collection of items that need to be processed. Processing each item involves sequential calls to various services. The services return a ...
user avatar
  • 131
4 votes
2 answers
506 views

Recurrent action on concurrent collection

I have a bunch of concurrent threads carrying out operations which return alerts. The alerts have to be persisted to a DB, but this cannot be done concurrently as it may cause duplicate alerts being ...
user avatar
  • 175
3 votes
2 answers
2k views

C++ concurrent queue and testing

I've written concurrent queue based on std::queue. ...
user avatar
  • 131
4 votes
2 answers
130 views

Filter request code handler

I use the following code which works OK, the code is filtering requests and in case there are too many requests it sends some logs/errors since I'm very new to Java my question if there is a better ...
user avatar
  • 281
2 votes
1 answer
223 views

Executing an SQL command on a number of files

Is this thread safe? I have a program that executes an SQL command on a number of files (selected by the user). Here is where I create the threads: ...
user avatar
2 votes
1 answer
1k views

Ensuring no race conditions in my concurrent/parallel ForEachAsync method

Hopefully the final chapter of my ForEachAsync code review. The original question was the starting point and the second question contained modifications suggested ...
user avatar
  • 219
5 votes
1 answer
7k views

Semaphore based concurrent work queue

There's a need to have a mechanism in place that will process messages received from the network concurrently. However, only X number of messages can be allowed to be processed concurrently and there'...
user avatar
  • 163
8 votes
1 answer
1k views

Constant keys thread safe dictionary

I find that I use this pattern a lot where I have a dictionary which I would only read from and update and wouldn't add/remove keys. In that case, using ...
user avatar
  • 191
4 votes
1 answer
4k views

Concurrent/parallel ForEachAsync - proper handling of exceptions and cancellations

I've created an asynchronous parallel ForEach mechanism so I could enumerate an enumerable by N degrees of concurrency and process an action for each item. ...
user avatar
  • 219

1
3 4
5
6 7
9