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 ...
0
votes
1answer
50 views
Simple parallel_for_each in C++
I need to parallelise a for loop that does quite a lot of processing over thousands of items. I came up with this basic loop that seems to work quite effectively on ...
0
votes
0answers
24 views
The right way to synchronize on non-final object in Java [closed]
Hello, everyone!
I'm trying to protect object with lock.I didn't chose mutexes because of ugly syntax of "try..catch".Browsing stackoverflow I came to a conclusion thatthis is how to properly achieve ...
1
vote
0answers
34 views
Wikipath stack in Java - Part I/IV - The search algorithm
I am working on the following small software stack:
The objective of the entire stack is to search for shortest paths in the Wikipedia article graph as fast as possible. As of now, I rely on two ...
6
votes
5answers
852 views
A buffer that holds and provides the latest n items
I have developed the following code to hold n latest items it has received, and when asked for provide these n latest items.
The interface is:
...
3
votes
1answer
50 views
A receptive map queue
I've written a class I call ReceptiveMapQueue. It's purpose is to organize the internal structure of an AFKable RPG. It only has two public methods - dumping entries into the queue, and extracting ...
0
votes
0answers
40 views
Ruby thread pool implementation
I'm in the process of adapting the simple thread pool described here to my application. I'm new to concurrency in Ruby, but here is what I have so far:
...
4
votes
2answers
101 views
Concurrent for loop in C++ - follow-up
I have incorporated all the cool points made by ChrisWue in the initial iteration of this post.
Now, I am not reinventing the wheel for my concurrent queue, but use internally ...
5
votes
2answers
65 views
Java controller to farm out concurrent tasks
I've recently given a coding interview on a Java concurrency task and unfortunately didn't get the job. The worst part is I've given my best but now I'm not even sure where went wrong. Can anyone ...
5
votes
1answer
181 views
Concurrent for loop in C++
(See the next iteration.)
I have this easy to use facility that maps input elements to output elements concurrently by the means of a thread pool:
concurrent.h:
...
4
votes
4answers
156 views
Implemenation for concurrent file access (read/write)
I am developing an application that works with files and folder on a network share (similar to the windows explorer). The application is used by multiple users and provides some commands for modifying ...
1
vote
1answer
59 views
Multithreaded Producer-Consumer pattern
I have Producer Threads A, B and C producing 3 different types of events Events A, B and C respectively. The Consumer thread can ...
2
votes
1answer
38 views
Managing PostgreSQL transactions for concurrency
I have a situation where I need to use PostgreSQL's serializable isolation level for transactions. This is for a table shared among multiple concurrent PHP processes. If the database runs into any ...
9
votes
2answers
180 views
Naive parallel Sieve of Eratosthenes in Java
My naive version now is too slow. I think setting/accessing concurrent atomic bit is way slower compared to access/modify an array of boolean. Second, the parallel execution only happens on the ...
0
votes
0answers
129 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 ...
3
votes
1answer
105 views
Concurrent non-blocking update of cached list of on-line users
I have following problem: My server (ASP.MVC WebAPI) is tracking, when client application ("Agent") is on-line. It's storing this inf on following table:
...
-2
votes
1answer
27 views
Capture some state in Haskell
I want to capture some state in a Haskell function. For instance, I have many thread trying to print on the console and I want the to play nice with each other. So I want to have some XX to make the ...
2
votes
3answers
111 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 ...
1
vote
0answers
38 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.
...
4
votes
0answers
84 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 dfs on it.
How can I make the ...
3
votes
1answer
197 views
Reader-writers problem using semaphores in Java
I have written my own solution to the Reader-Writers problems using semaphores based on the psuedocode from Wikipedia. I would like to gauge the correctness and quality of the code.
...
2
votes
0answers
85 views
Concurrent resizable ring buffer Golang
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
(...
1
vote
1answer
147 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
0answers
82 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 ...
4
votes
1answer
56 views
Multiple Persons enter room simultaneously and exits after specific interval of time
Here is the link to git repo of my application I am currently implementing just to have better understanding of OOP as well as learning Concurrency (Atleast a try :D)
What is the whole ...
4
votes
2answers
96 views
Go lang Tour Webcrawler Exercise - Solution
I am new in Go and for study I have to hold a presentation about concurrency in Go. I think the Go lang Tour - Webcrawler exercise is a nice example to talk about that. Before I will do that, it would ...
0
votes
1answer
91 views
Design of thread pool reuse with Executors.newFixedThreadPool in Java
In my application I have code which should run every hour on a new items and execute some expensive operation with multithreading:
...
1
vote
1answer
189 views
Thread safe REST API
My assignment was to develop a REST service that will provide Airport information. This service is assumed to be used by multiple users, therefore data consistency (thread safety) and responding fast ...
2
votes
1answer
175 views
A very basic semaphore in Java
Here is is a fixed code, taking in to account Spurious wakeup issue.Thanks to Costa for bringing that up.
ISemaphore:
...
3
votes
1answer
56 views
A scalable lock-free channel
Here's my lock-free channel impl lfchan,
I didn't want to copy/paste the code here since it is multiple files.
I'm trying to get an idea of what can be improved or if there are any bugs in it.
chan....
1
vote
2answers
86 views
Processing files retrieved through FTP in parallel
I am busy creating a file processor that needs to get some files from an Ftp client download the file and save the data into the database. I have a two part question.
How can i refactor the code to ...
0
votes
2answers
34 views
Initialization lock for singleton
I'd like someone to double-check my use of Atomic primitives, because multi-threading is hard.
What I don't want to do is locking the whole get method, or having too many pre-checks per get() call.
<...
0
votes
0answers
9 views
Robustly send notifications from multiple processes
We have Notifications stored in a notifications table, which is worked on by multiple background workers. The notifications table has these relevant attributes:
id (primary key, unique)
send_at (...
6
votes
1answer
83 views
Can my cache be more thread safe?
I have been working on a cache that can handle multiple reads at the same time, but the write is blocking.
Is this code overkill by using both a ConcurrentHashMap ...
4
votes
1answer
47 views
Reporting the status of the actions of a group of SKSpriteNodes
Working on a little Sprite Kit game, I had the problem that I wanted a couple of things to wait until a group of sprite nodes had stopped their animation.
I decided to use a GCD dispatch group to ...
2
votes
1answer
29 views
Distributed (asynchronous) averaging
This code simulates a distributed averaging protocol. There is a network of nodes, and at the clicks of a Poisson process:
A random node wakes up
Transmits it's current average to all the nodes it ...
0
votes
1answer
48 views
Tree processing for series and parallel execution
I have a tree processing application where some of the nodes are "executed" in parallel and some in series. I managed to do this but I feel that the solution looks a bit "hacked up" and can be ...
1
vote
1answer
457 views
Executor Service with Blocking Queue
I did not find a single working implementation of using an Executor Service with a Blocking Queue. So , I have come with with a working sample. Thoughts?
...
2
votes
0answers
31 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
1answer
438 views
Parallel Task Queue that runs in sequence
I'm in need of a solution that runs constantly incoming requests in a per-resource sequence, but parallel in general.
The use-case:
Many clients connect to a server and start issuing work. The work ...
1
vote
0answers
38 views
Purging elements from the map if it reaches a memory size limit
I have implemented a LRU cache using ConcurrentLinkedHashMap. In the same map, I am purging events if my map reaches a particular limit as shown below.
I have a ...
5
votes
3answers
213 views
Simple Java task scheduler
The task is pretty simple: implement a timer that executes tasks when the next event takes place. I created a task scheduler based on a priority queue.
A new thread is created for ...
7
votes
1answer
39 views
Refactoring a phantom server called Swayzee
I have made a tool that is pretty useful for me. I have made it open source on github. It is a server that listens for requests and returns an HTML static version of a single page app. It works with a ...
3
votes
0answers
48 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, ...
2
votes
1answer
119 views
Unfair semaphore in Java
I'm tutor for a university operating systems course, and part of my work is creating exercises for them. Those exercises are mostly about concurrency and synchronization issues. For the next exercise ...
4
votes
2answers
180 views
Parallel foreach with configurable level of concurrency
The purpose of this code is to let me loop over 100 items (up to MAX_CONCURRENT at a time), performing some action on them, and then return only once all items have ...
0
votes
0answers
89 views
RabbitMQ RPC client
I'm familiarising myself with RabbitMQ and Clojure, so I looked at the Get Started guide for the former and added the client and server parts for the RPC tutorial.
I already got the feedback that ...
10
votes
1answer
100 views
ConcurrentDecayingHashMap<K,V>, a concurrent decaying HashMap
I wrote a wrapper for Java's ConcurrentHashMap that enables you to add a decay time to inserted values, meaning they will be automatically removed after the given ...
3
votes
2answers
47 views
Visualize the runtimes of list algorithms
I wrote a small script to visualize the runtimes of list algorithms.
The script works by creating a list of lists with sampled lengths from 1 to max_size. Next, I ...
5
votes
1answer
63 views
Lock implementation using atomics
I was recently given an interview and was asked to write my own lock implementation using atomics, but not necessary reentrant.
I didn't answer the question, but at home, I wrote this code. Please ...
10
votes
1answer
237 views
“Barbershop”-esque Semaphore Implementation
Recently, I submitted a project that simulates a barbershop-style problem; the task was to create a Hotel that contained guests, front-desk employees, and bellhops. ...