As of May 31, 2023, we have updated our Code of Conduct.

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
1 answer
130 views

Java Concurrent Recursive API Access

I don't get to write multithreaded applications very often, so be gentle with my threads :-) I have an API input which contains a "score" and then a bunch of child nodes which also have scores, and ...
charstar's user avatar
4 votes
0 answers
209 views

Drawing the Mandelbrot with multiple threads in rust

The code below draws the mandelbrot set for { z | z∈ ℂ, -2.2 ≤ Re(z) ≤ 0.6, -1.4 ≤ Im(z) ≤ 1.4} into a 300×300px png image. For each pixel, if the sequence {zi} is found to ...
Yosh's user avatar
  • 277
4 votes
1 answer
467 views

HTTP Load test with Golang

I am a golang novice... I am trying to write an application that takes in many requests - up to a sustained 10000 HTTP posts/sec and post the payload to two back-ends in parallel (5 second timeout). ...
phil swenson's user avatar
2 votes
1 answer
229 views

Concurrent access to data with QReadWriteLock

Using Qt, I've got this code in order to protect access to some shared data between threads. I'm pretty sure the idea is correct, but I don't know if RVO and/or RAII could potentially screw the ...
Raziel's user avatar
  • 108
3 votes
1 answer
2k views

Concurrent fire and forget async task queue

I had to do a lot of IO stuff on my server running Node JS where I did not really care about the result of the operations. The list of incoming tasks could be huge, so I had to limit the number of ...
Endauriel's user avatar
  • 153
4 votes
0 answers
274 views

An in-memory copy of the GDAX order book for an arbitrary cryptocurrency, updated in real time

GDAX is the cryptocurrency exchange owned and operated by Coinbase. This code is intended to be the basis for an order-book-strategy trading bot. I'd love feedback on my use of data structures, my ...
feuGene's user avatar
  • 363
1 vote
1 answer
189 views

Go task scheduler

This is the same problem as the Python task scheduler, but in Go. I chose not to use a sync.Cond (I couldn't seem to get that right), but instead use channels. <...
yangmillstheory's user avatar
3 votes
1 answer
165 views

Issue tokens concurrently with synchronization per client

I have an API application with token authorization. A token is valid for one hour. Each business client has its own instance of the API application: ...
mtkachenko's user avatar
1 vote
0 answers
89 views

Asynchronous Message Passing

I'm implementing a method which has the purpose of waiting for a message (boolean value). Works, but can it be improved? Code: ...
Robert Hanigan's user avatar
1 vote
0 answers
37 views

Implementation of an ObjectPool

we are trying to implement an object pool. The objects contained are reusable but not thread safe, and creation costs a lot so we went with this idea. We expect that the user of this object will need ...
dierre's user avatar
  • 239
4 votes
0 answers
438 views

ConcurrentLinkedQueue Object Pool implementation

I have implemented this simple unbounded ObjectPool based on a ConcurrentLinkedQueue of WeakReferences. I have a thread-unsafe object that is pretty expensive to create, and most of the time it will ...
Juan Lopes's user avatar
10 votes
1 answer
153 views

Simple concurrency implemented in Python

Purpose of the question: learn more about ways to implement concurrency in Python / experimenting. Context: I want to count all of the words in all of the files that match a particular pattern. The ...
Michael's user avatar
  • 285
3 votes
1 answer
67 views

Concurrent Data Manager with minimal synchronization

So I have my own library to organize advanced critical sections at GitHub. It's based on the ResourceDataStorage class which is responsible for creating, storing and clearing resource records. I've ...
Zur13's user avatar
  • 133
4 votes
1 answer
91 views

ReadWriteSerializer

I am developing a C++ kernel, and I've got the need for manipulating huge data structures before the task-scheduler runs - it means in a non-preemptive environment. For this, I have developed a read-...
Shukant Pal's user avatar
2 votes
2 answers
1k views

Concurrent hero vs monster program

I have made a simple concurrent program. It represents a battle between a hero and a monster. I am beginner in concurrency so I just want to hear your opinion. What are bad and good sides of my code ...
Dejan Ilic's user avatar
2 votes
1 answer
126 views

Use of concurrency to generate combinations

I have the following package to generate combinations from a slice of bytes: ...
James K's user avatar
  • 731
4 votes
1 answer
579 views

Worker, Pool and Jobs

I created a snippet of code that allows me to create a worker pool, and from that worker pool I can run a bunch of jobs. I can configure each job to have a retry limit, and set a callback that will ...
Lansana's user avatar
  • 397
2 votes
0 answers
70 views

Pub/Sub Broker Subscriber Interface

I'm working to build out a Subscriber interface for handling at-least-once messaging semantics, so I can produce different brokers. Here's my interface thus far: <...
DMac the Destroyer's user avatar
7 votes
1 answer
1k views

Tool to calculate the average time that takes for a GitHub pull request to get merged

I'm learning Go, and this is my first attempt at a command-line tool that uses the GitHub API to calculate the average time that takes for a pull request to get merged for a particular organisation or ...
UnsafePointer's user avatar
1 vote
0 answers
52 views

Race condition of initialization with fail safe

I have the following usecase, I have a multi threaded environment and I want to initialize some parameters only only. The thing is that when I initialize the parameters I call a function that ...
Anton.P's user avatar
  • 193
7 votes
1 answer
375 views

A Game of Life application, with mouse clicks

I have a Game of Life program that has a grid[][] array which is populated by Cell objects. If there's a cell in a grid square, ...
woodStone's user avatar
  • 143
0 votes
1 answer
129 views

A portable parallel loop construct in C89 - follow-up

This is a follow-up question to A portable parallel loop construct in C89. I have incorporated all the good points made by vnp. Now my code looks like this: parallel_for.h ...
coderodde's user avatar
  • 26.7k
7 votes
1 answer
866 views

A portable parallel loop construct in C89

(There is a next iteration available.) I was practicing writing some portable C89 code and came up with this parallel for loop construct. Basically, if you have a ...
coderodde's user avatar
  • 26.7k
1 vote
0 answers
185 views

Implementation of a cellular automata to model breast cancer

I've created a program - it's an implementation of the cellular automata described in this paper (can't find a free PDF, sorry - anyway it's not really relevant to this question). The CA is ...
Kovalainen's user avatar
4 votes
1 answer
3k views

A "zero copy" concurrent queue in C++ that supports exactly two threads; one for pushing and one for popping

One thread is limited to one action (i.e. there is a push-thread and a pop-thread and the push-thread can't pop and vice versa). By "zero copy" I mean no copying of data (mostly C++ structures) will ...
Chani's user avatar
  • 273
1 vote
1 answer
71 views

Modelling deadlock in cyclic pipelines in Haskell with coroutine libraries

I'm modelling two processes which have been put into a cyclic pipeline - the output of each feeds into the input of the other - so as to work out when they've deadlocked (i.e., neither can progress ...
phlummox's user avatar
  • 218
3 votes
1 answer
273 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 ...
david's user avatar
  • 1,647
2 votes
1 answer
6k 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 ...
david's user avatar
  • 1,647
1 vote
1 answer
466 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 ...
tuk's user avatar
  • 111
2 votes
1 answer
229 views

Stack for asynchronous processing

The following TaskStack processes input elements asynchronously based on a function that it receives at construction: ...
Matthias Braun's user avatar
1 vote
0 answers
119 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 ...
Christian Hujer's user avatar
2 votes
0 answers
209 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 ...
user3017869's user avatar
2 votes
1 answer
331 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 ...
david's user avatar
  • 1,647
2 votes
1 answer
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 ...
NiK's user avatar
  • 123
1 vote
0 answers
750 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 ...
June's user avatar
  • 11
3 votes
1 answer
4k 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 ...
Bobloblawlawblogs's user avatar
4 votes
0 answers
431 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)...
Luca Sepe's user avatar
  • 141
1 vote
0 answers
856 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 ...
benjamin c's user avatar
3 votes
0 answers
480 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 ...
iusctx's user avatar
  • 31
11 votes
1 answer
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 ...
david's user avatar
  • 1,647
6 votes
5 answers
569 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 ...
Todd Takala's user avatar
1 vote
1 answer
517 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 ...
nbui's user avatar
  • 13
3 votes
2 answers
243 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 ...
Jepzen's user avatar
  • 131
3 votes
1 answer
891 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...
Chris B's user avatar
  • 133
2 votes
1 answer
190 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 ...
justaguy's user avatar
  • 123
5 votes
2 answers
934 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 ...
Quuxplusone's user avatar
  • 19.2k
1 vote
0 answers
182 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 ...
Phoenix's user avatar
  • 267
1 vote
1 answer
178 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 ...
rnso's user avatar
  • 241
3 votes
1 answer
555 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 ...
cramopy's user avatar
  • 203
3 votes
1 answer
90 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 ...
Mike -- No longer here's user avatar

1 2 3
4
5
10