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.

74 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
0answers
67 views

Implementing GSL synchronized_value

Core Guidelines mention a type synchronized_value<T>, which supposedly pairs std::mutex with the internal value. I couldn'...
6
votes
0answers
628 views

Pseudo-parallel depth-first search

I'm writing a small program that generates a file containing an adjancency matrix, it then reads from that file, constructs a graph and does something like a parallel depth-first search (dfs) on it. ...
5
votes
0answers
146 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 ...
4
votes
0answers
94 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 ...
4
votes
0answers
217 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 ...
4
votes
0answers
689 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 ...
3
votes
0answers
20 views

n executions of a periodic goroutine

I'm new to Go and have a use-case for periodically executing an async work-function. I want the interval between work-function executions to be constant (not the time between one finishing and the ...
3
votes
0answers
971 views

Hosted service for queuing and running tasks in parallel in ASP.NET Core

I am attempting to construct a background service for an IIS-hosted ASP.NET Core project that basically queues tasks and runs them, and I decided to go with the ...
3
votes
0answers
42 views

Concurrency control between a non-blocking and a blocking methods

In this program, there is a list of Holders that is managed by a singleton class. Each of the Holders keeps a copy of the ...
3
votes
0answers
472 views

Linked list with hand-over-hand locking

Follow-up to this question: after reading the comments, I decided to redesign my linked list to have a cursor that only contains one node and implement the interface similar to the one of forward_list ...
3
votes
0answers
68 views

Override prototype inside of constructor of ES6 class for dependency injection

We implemented a small dependency injection mechanism which we use in our project. Now after 2 years of developing our project we need our classes to know who instantiated them via dependency ...
3
votes
0answers
198 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 ...
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)...
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 ...
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 ...
3
votes
0answers
491 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 ...
3
votes
0answers
50 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 ...
3
votes
0answers
61 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: ...
3
votes
0answers
75 views

Methods to add and check elements in a Bloom Filter

I have a working Java implementation of Bloom Filter. These are the methods to addElement and check for an element. ...
3
votes
0answers
537 views

Golang Tour Web Crawler Exercise

In the last few days I've played around with Go a little and took the language tour. The last exercise (text here) requires you to crawl a graph that simulates a set of Web pages with links, using ...
3
votes
0answers
126 views

Implementing a long-running entity lock

Requirement I have an entity named ImportData which can be processed once in order to extract data from a file fed to the application. I need to make sure that, in ...
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, ...
2
votes
0answers
69 views

Concurrent execution and coordination of C# tasks

I have a class, 'TaskCoordinator' which has 'BaseTask's applied to it. The BaseTasks have OnStarted, OnFinished and OnCancelled events which are triggered to notify the calling class of their events....
2
votes
0answers
41 views

Comparing Java Semaphore versus ReentrantReadWriteLock

In this post, I attempted to compare the performance of two concurrency constructs: java.util.concurrent.Semaphore, ...
2
votes
0answers
435 views

Many-readers-one-writer with semaphores and multithreading

I've been looking for a solution to the may readers one writer in Java. I was intrigued by this question posted here and I read the Wikipedia entry about it. So far, I've reached a fine solution, or ...
2
votes
0answers
760 views

Golang gRPC context to check if cancelled or if deadline is exceeded while running function code

I am writing a gRPC Golang application and am looking for the best way to check if the deadline is exceeded or if the client cancelled the call. On the server side I created a channel called ...
2
votes
0answers
39 views

Comparing performance of multi- and single - thread search of a maximum number

I have a class that compares the performance of two methods (multi- and single- thread) that searches for maximum number in the string of numbers. I want to improve the performance of a multithreaded ...
2
votes
0answers
65 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: <...
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 ...
2
votes
0answers
163 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 ...
2
votes
0answers
577 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 ...
2
votes
0answers
373 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 ...
2
votes
0answers
457 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 ...
2
votes
0answers
3k views

Golang: reading and writing files in parallel

I am trying to read a big file line by line, inspect and cleanse each row and write to either of two output files depending on the outcome. I am using channels for this. I am still quite new to this ...
2
votes
0answers
556 views

Concurrent resizable ring buffer

I'm trying to find the fastest way to enqueue and dequeue items concurrently in Go. There are some restrictions: it needs to be unbounded Memory allocation should be low Multiple producers (Single ...
2
votes
0answers
150 views

Frequency of words in all files of a directory using Future - Scala

I created a program to get frequency of word in all files in a directory using Future API ...
2
votes
0answers
97 views

Parallelized image transformations using GraphicsMagick

This is part of a script that I use for porting a TWRP theme from one resolution to another, respectively portrait to portrait and landscape to landscape. In this function entirely, it focuses on the ...
2
votes
0answers
95 views

Porting Java semaphore to MacOSX

I wanted to write some more JNI code and decided to (re)implement a semaphore for MacOSX. In order to assert somehow correctness of my implementation I hereby supply a (multi)consumer/(multi)producer ...
2
votes
0answers
586 views

NoSQL-based sequence generator

For my web application I have to generate a sequence of following format: <year><sometext><month><sequence> For example: ...
2
votes
0answers
515 views

WebApi synchronize database (EF 6) access

I'm working on an ASP.Net MVC 5/WebApi 2 project. I'm using EF 6 code first for my database access. I have a WebApi action method in which I've to update some data in my database based on the request....
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. ...
1
vote
0answers
46 views

Why is my Python thread pool faster than my Go worker pool?

I have recently been digging into understanding Golang concurrency, in particular the use of channels and worker pools. I wanted to compare performance between Go and Python (as many have done) ...
1
vote
0answers
40 views

infinite generator with eviction

I made a struct that will loop through a list, and return the next element on calls to the Get() method. It also allows to remove elements from the list by calling the Evict() method, and is safe for ...
1
vote
1answer
212 views

Thread Safe Bank Transaction: Deposit, Withdrawal, Check Balance and Transfer in Java

I have made a class which is a thread-safe implementation supporting Deposit, Withdrawal, Check Balance Querying and Transferring of money. I have a class Account: ...
1
vote
0answers
21 views

Take a list of ascii strings from a file and hash them using python threading

How can I do this in a more performant way? I'm concerned that throwing the data in a queue like this is defeating the purpose of yield from the ...
1
vote
0answers
73 views

Critical section around given key

I would like to know if there is any pre-existing implementation of my solution so I don't have to reinvent the wheel. What I'm trying to create is an utility which allows me to create critical ...
1
vote
0answers
162 views

Using ReadWriteLock to implement a cache access guard

In my project, there is an internal cache api to use. I have noticed an emerging pattern such that: ...
1
vote
0answers
188 views

Thread-safe Java class for managing XML files <> domain models

This Java class (aka application component) role is to handle a series of XML files stored in the file system. It must convert those XML files to the corresponding application domain model, and it ...
1
vote
0answers
315 views

Concurrent hash map implementation with Go's channels

I've implemented a concurrent hash map in Go. I'm fairly new to this language as I have mostly Python background so I'm looking for suggestions how to improve my code. I've ran the tests with ...
1
vote
0answers
17 views

JSON API Scraper v2: Limited concurrency AJAX from a shared queue (ES2017)

Essentially the AJAX component of this question, reimplemented in ES2017 style async/await. The code connects to a remote JSON API and scrapes it using a limited number of streams to avoid triggering ...