Skip to main content

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
69 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 ...
4 votes
1 answer
615 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 ...
2 votes
1 answer
130 views

Use of concurrency to generate combinations

I have the following package to generate combinations from a slice of bytes: ...
1 vote
1 answer
726 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 ...
4 votes
1 answer
96 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-...
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 ...
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: <...
3 votes
3 answers
4k views

Implementing a thread-safe factory with caching

I have a ConnectorFactory that creates Connector objects based on parameters like URLs, username and passwords. The ...
4 votes
4 answers
5k views

C++11 Blocking Queue learning exercise

As part of my own C++11 learning exercise I have implemented this Blocking Queue using the new C++11 thread API. One of the aspects I would like to improve is efficiency i.e. in the ...
0 votes
1 answer
139 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 ...
7 votes
1 answer
908 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 ...
1 vote
1 answer
76 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 ...
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 ...
1 vote
1 answer
570 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
1 answer
276 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
1 answer
7k 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
1 answer
504 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
1 answer
352 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
1 answer
244 views

Stack for asynchronous processing

The following TaskStack processes input elements asynchronously based on a function that it receives at construction: ...
5 votes
2 answers
167 views

Concurrent task pool

My use case is to dispatch multiple long-running tasks to execute concurrently. The expectation is that the tasks will be IO-bound (e.g. network requests), but importantly each task is different. This ...
2 votes
0 answers
517 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
1 answer
1k views

Performing tasks concurrently

I made a class to perform tasks concurrently and have implemented it. From appearances and testing, everything seems to work. How can I improve this? I understand this is somewhat a broad question, so ...
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 ...
2 votes
0 answers
224 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
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 ...
1 vote
0 answers
771 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
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 ...
1 vote
1 answer
194 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 ...
4 votes
0 answers
433 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
0 answers
939 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
1 answer
195 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, ...
5 votes
1 answer
6k views

Reading and processing a big CSV file

I am trying to write a script to read a CSV file containing 1 million domain names, look up these domain names and store the results in another CSV file. I am trying the following code, but the number ...
3 votes
2 answers
308 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
1 answer
933 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
1 answer
210 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
2 answers
1k 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 ...
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 ...
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 ...
3 votes
1 answer
670 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
1 answer
108 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
1 answer
2k 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
0 answers
117 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
2 answers
2k views

C++ concurrent queue and testing

I've written concurrent queue based on std::queue. ...
4 votes
2 answers
714 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 ...
6 votes
3 answers
345 views

URLEncoder implementation

I'm looking for feedback on my URLEncoder implementation, which is a drop-in replacement for Apache Tomcat's URLEncoder. It was ...
5 votes
2 answers
624 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 ...
5 votes
1 answer
63 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 ...
6 votes
1 answer
2k 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 ...
3 votes
2 answers
1k 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 ...
5 votes
2 answers
2k 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 "...

1
3 4
5
6 7
10