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

Managing socket pool per datacenter

I have a list of sockets per datacenter (in general, I have around three datacenter and each datacenter having 20 sockets, so in total I have around 60 sockets). Now I have 20 business threads which ...
2
votes
1answer
4k views

Send data on a socket from multiple threads

I have around 60 sockets, 20 business threads and 1 pinger timer thread and I want to make sure each of those thread works on different socket every time so I don't want to share same socket between ...
1
vote
1answer
314 views

ArrayBlockingQueue in which queue head is removed if the queue is full while adding an element

I am trying to write a simple queue like ArrayBlockingQueue in which the head of the queue will be removed if the queue is full while adding an element. The class should just have the below public ...
2
votes
1answer
171 views

Stack for asynchronous processing

The following TaskStack processes input elements asynchronously based on a function that it receives at construction: ...
1
vote
0answers
90 views

Echo in Prolog with single print (new version)

In order to learn a bit more of Prolog, I implemented the echo command for SWI-Prolog. I want a correct implementation, that is, it satisfies the following requirements: It makes only one I/O call ...
1
vote
0answers
128 views

Golang: Improving communication between workers

Came back to the software side of my night vision security camera project after taking some time to learn about electronics and I found it a bit hard to retrace the logic of my program. I have a ...
2
votes
1answer
256 views

Send records and retry them if acknowledgement is not received

I am using below class to send data to our messaging queue by using socket either in a synchronous way or asynchronous way as ...
2
votes
1answer
2k views

Processing concurrent AJAX requests

I am trying to process concurrent AJAX requests with vanilla JavaScript. Below is the sample code I've been working with ...
1
vote
0answers
665 views

A semaphore implmentation with Peterson's N process algorithm

I need feedback on my code for following statement, am I on right path? Problem statement: Implement a semaphore class that has a private int and three public methods: init, wait and signal. The ...
3
votes
1answer
3k views

golang concurrent tcp server

Go and concurrency noob here. I wrote a program to handle a tcp connection to index (and removes) packages. I want it to be able hundreds of connections and messages that might come in at the same ...
3
votes
0answers
383 views

Custom ThreadPoolExecutor/ThreadFactory in order to submiting callables upon incoming ActiveMQ messages

I have a service that is subscribed to a specific channel of ActiveMQ. Every time a message arrives the service has to start a "job" (submit instances of Callables)...
1
vote
0answers
622 views

Socket server with consumer-producer design to handle concurrent connections

The usual way is to implement socket server to handle concurrent requests by creating new thread for each request. Instead of this approach i tried to create a server using ...
3
votes
0answers
267 views

Python coroutines to write files

I'm refactoring a monster 176-line function into something more sensible and more testable. The function as it stands fails the 'one thing and thing well' test by doing many things: Indexing through ...
11
votes
1answer
2k views

Do not share same socket between two threads at the same time

I have a code in which I am dealing with sockets and I need to make sure that I don't share same socket between two threads. In my below code, I have a background thread which runs every 60 seconds ...
6
votes
5answers
343 views

Convert FLAC files to MP3 in parallel on Ubuntu

I created a script to convert my FLAC music collection to MP3. I did this so that I can play the MP3 files in my car, as the integrated head unit only supports MP3 and WMA files. The script works on ...
1
vote
1answer
299 views

Heartbeat Server

I'm writing a toy heartbeat server. Each client, upon loading, registers itself and thereafter, sends heartbeats every X seconds. The server checks every ...
3
votes
2answers
157 views

Getting a serial number from shared table

I have a table that keeps track of a global serial number shared between several tables. This is not the PK or unique id for each table. It is like a case identifier. Every time users create a new ...
3
votes
1answer
760 views

Independently constraining task parallelism at different levels of a nested loop

I would like to performance test a REST API using C#. The API offers a list of endpoints, and each endpoint accepts page and size...
2
votes
1answer
99 views

Extracting large tar.bz2 folders in parallel

The bash below utilizes parallel to extract tar.bz2 folders with 9 files in them. The total size of each is around 60GB. Below ...
5
votes
2answers
619 views

Non-polling implementation of std::when_any()

The following — I claim — is a implementation of when_any from the C++ Concurrency TS, except without all the baggage around ...
1
vote
0answers
95 views

Purely functional octree and octree priority queue

I'm programming a game in Scala, and a lot of tasks are able to be done in the background. I've created a system in which each Future can be assigned a position in 3d space, and they are stored in an ...
1
vote
1answer
138 views

Permutation-stream based n-queens solution

Following is a very crisp solution for solving n-queens problem in Racket programming language. The method is to get all permutations (so that no 2 queens are in same line) and to check these for any ...
3
votes
1answer
229 views

Process array with x parallel executions

I wanted to create a function in JavaScript using jQuery's Deferred which executes a given function for each element in an array. The function is intended for ...
3
votes
1answer
51 views

Two bidirectional Software UARTs with AT89S52 microcontroller

I have learned one way to read from a serial port via software UART is via timer interrupts. I have made an implementation of receiving data from one serial port below. I haven't tested it yet because ...
2
votes
1answer
1k views

Java Concurrent Multimap

I've implemented a concurrent multimap that support concurrent put and remove but I'm unsure of its correctness. I would appreciate your feedback. ...
3
votes
1answer
136 views

TimeoutManager: check whether a task has been finished within a given time

I want to make a helper class, which raises an event whenever something is not finished in a certain time. Example: my program sends out multiple network messages concurrently. After a random delay, ...
4
votes
2answers
577 views

Pausing and resuming a concurrent database update queue

I have a class DatabaseQueue which asynchronously runs SQLite updates that it takes from a LinkedBlockingQueue. I implemented a ...
3
votes
0answers
108 views

Concurrency using immutability

I was watching the following video about software transactional memory(using a package that maintains an access log). At the moment I am trying to learn about concurrency with shared memory and ...
5
votes
2answers
421 views

Thread-safe BitArray

Notes: supports 64-bit platforms only ulong used where negative values make no sense library functions are assumed to be correct (whether they actually do what I ...
8
votes
1answer
719 views

Dynamically extensible threadpool implementation in C

Purpose For my recent project, I needed a thread pool. I saw a lot of implementations at GitHub, but most of them were quite complicated. With complication comes performance penalty. Most importantly,...
6
votes
1answer
1k views

Thread safe ConcurrentDictionary wrapper

I needed some features that ConcurrentDictionary doesn't have (such as a maximum number of items) so I created a wrapper around it. This is my first time working ...
1
vote
0answers
81 views

Answering Master Clojure for the Brave and True - concurrency exercises

I recently answered the two exercises at the end of this chapter of Clojure for the Brave and True (see the end of the page). First exercise: count words in random quotes (in parallel) This is my ...
2
votes
1answer
1k views

Limiting the maximum amount of goroutines run simultaneously

Here is my code which helps me to contol the maximum amount of goroutines run simultaneously. In example below maximum is 5. ...
3
votes
2answers
513 views

HackerRank challenge to count ways to climb a staircase, solved using Java Fork Join

I'm trying to solve Stair case recursion problem on HackerRank. The problem is to find all possible ways for a child to climb a stair case with height n given that ...
3
votes
2answers
252 views

ConcurrentHashQueue in C#

The ConcurrentHashQueue data structure is a FIFO queue that at the same time allows look-ups of items based on a key in O(1) like a dictionary. It can be used as a ...
3
votes
1answer
2k views

Work stealing queue

I implemented work stealing queue inspired by Sean Parent's talk on code::dive 2016. Full implementation is here. I am looking to get feedback on improvements to make code more effective and common ...
5
votes
2answers
1k views

Golang concurrent writer

I wrote a program that concurrently reads multiple files and makes a request to an API for each line of each file. The JSON response is then parsed and the "available_filters" field is extracted. The ...
0
votes
1answer
1k views

Sum and stock size concurrent code using Executor

The code should parse the input values and calculate the sum and size of particular stocks, using Executor thread pool by dynamically adding the thread count. Please review the following code for ...
2
votes
0answers
165 views

Using blocking queue to calculate data stream - Generalized

A followup on my previous question Using blocking queue to calculate data stream. This time suppose we have a list of blocking queues as stated in the following manner: Suppose you have a list of ...
1
vote
1answer
383 views

Find pairs of consecutive numbers fetched from blocking queues

I was coding for the following programming question: Suppose you have two independent blocking queues that will keep getting new data, the new data will always be greater than the last element of ...
3
votes
1answer
3k views

Matrix multiplication with OpenMP parallel for loop

I tried implementing matrix multiplication with parallel for loop in OpenMP as follows. It runs correctly but I want to make sure if I'm missing anything. How does this determine the number of threads ...
1
vote
0answers
83 views

Synchronous cinema hall, with StampedLock

I'm beginner in Java concurrency mechanism. I wrote some application to train a synchronization between many threads. I noticed that I wrote a lot of if statements, and it looks really ugly. Maby is ...
5
votes
2answers
713 views

Concurrency-safe stack implementation in Go

As Go doesn't come with a lot of collection structures, I've implemented stacks myself, building off some sample code I found floating around. I've then tried to extend it further by: Making a "...
5
votes
1answer
56 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 ...
1
vote
0answers
75 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 ...
4
votes
2answers
184 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 ...
4
votes
1answer
2k 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 ...
3
votes
0answers
490 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 ...
8
votes
3answers
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 ...
3
votes
1answer
735 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 ...

1 2
3
4 5
8