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 ...
4
votes
0answers
25 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
26 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
0answers
25 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
65 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
23 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
80 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
29 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
107 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
36 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
41 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
68 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
101 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
52 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
85 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
3answers
42 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
58 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
183 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. ...
7
votes
1answer
78 views
Fast non-fair semaphore
This is a simple non-fair semaphore implementation using Java atomic objects. It currently performs a little over twice as fast as java.util.concurrent.Semaphore on ...
1
vote
0answers
54 views
Self cancelling period tasks
I've got a piece of code that will run a period task to do a small bit of processing. The task depends on an externally managed connection resource, and if the resource goes away then the task should ...
0
votes
3answers
62 views
Implementing multiple Producer Consumer using custom Blocking queue [closed]
I am trying to implement multiple producer multiple consumer problem using a custom blocking queue. The requirement is that:
If the queue is not full, all the producers should be able to produce ...
6
votes
1answer
305 views
Printing even and odd using two concurrent threads
Please review the code below where thread Odd prints all odd numbers from 1 to 9 and thread Even prints all even numbers from 2 to 8. I tested it and it works but can we improve it from design or ...
4
votes
1answer
369 views
Canonical Implementation for a Concurrent Subclass of NSOperation in Swift 2
I would like to develop a kind of template or canonical implementation for a concurrent subclass of NSOperation in Swift.
See here for my previous request which is implemented in Objective-C.
In that ...
3
votes
3answers
100 views
SPSC Wait Free Ring Buffer for incoming messages
This is for a single producer and single consumer wait free ring buffer. The writes need to be wait free for sure. It pre-allocates messages slots and uses a claim strategy to capture a buffer for ...
0
votes
0answers
44 views
SQLite app for local storage
When I make an app using SQLite for local storage I've settled into a nice routine; create a contract class and a extended BaseColumns class to hold column names ...
0
votes
0answers
45 views
Having critical section for PHP using redis
Currently, I'm using redis to implement critical section for PHP code, to ensure there isn't more than one process/thread to execute the enclosed code block. I was wondering, is there any edge cases ...
4
votes
1answer
46 views
OutputStream class for use with subprocess.Popen
I've recently been writing an application which does a lot of work with the output of commands. To call the commands I've been using the subprocess module, and originally, was using ...
2
votes
1answer
61 views
Java “pulse” between threads
I have two threads. One runs a simulation and one runs a UI.
In the UI, it is possible to trigger a "tick" of the simulation. There are a few constraints:
Ticks run on the simulation thread
Each ...
3
votes
0answers
34 views
Baby Step Giant Step Discrete Log Solver
I've made a concurrent implementation of the Big Step Giant Step discrete log solver in Go. I'm pretty new to this branch of math, but it seems slow. Any way to speed it up or is this the limit of ...
3
votes
1answer
69 views
Parallel scheduler for running actions at designated times
I've been trying to learn Haskell on and off for a couple years. I had a project for building a parallel web scraper, and I figured I'd try to use Haskell for it. Here's the part used to schedule ...
6
votes
1answer
43 views
Class managing queuing updates from another thread, Version 2
This is an updated version of: Class to manage updates coming in from another thread
Managing updates from other threads into Swing is a hard problem. In MVC design, if you don't want to have the ...
1
vote
0answers
61 views
Batching using semaphores
I need to batch messages when pushing them, where multiple threads do the publishing. What could be a better way of doing this?
...
5
votes
2answers
61 views
Class to manage updates coming in from another thread
Managing updates from other threads into Swing is a hard problem. In MVC design, if you don't want to have the Presenter be responsible for Thread safety, you can end up with deadlock issues, and also ...
5
votes
1answer
83 views
Multi-threaded bitcoin vanity address generator written in Java
The application leverages the bitcoinj library to generate a vanity bitcoin address. A vanity address is simply a bitcoin address that contains a personalized string. I would like some critical ...
1
vote
1answer
60 views
ArrayBlockingQueue - blocking drainTo() method
This is a follow-up question to this question.
Is this a reasonable implementation for a blocking version of method ArrayBlockingQueue.drainTo(Collection)?
...
6
votes
1answer
69 views
Creating an in-memory ViewCounter that commits to database every 10 minutes
This singleton is responsible for counting every pageview (called Routes in our case) we get by id, until the timer runs out and commits the results to the database in one query. Then the counter gets ...
0
votes
0answers
89 views
2
votes
1answer
43 views
4
votes
3answers
431 views
Debounce in Scala
This is my attempt at implementing debounce in Scala without any 3rd party library. How can I improve the code/make it more idiomatic (and any bugs I might have missed)?
...
-2
votes
2answers
429 views
-2
votes
2answers
115 views
5
votes
2answers
351 views
Queue for distributing tasks between threads
I implemented the following class to dispatch std::function<void(void)> objects to a thread pool. Multiple threads will block on the pop call until a task is ...
11
votes
1answer
164 views
Concurrency interview
A little while back I had an interview where they posed a problem, in summary:
Watch a certain directory, and process incoming JSON files
These JSON files have various "Type" fields
Every second ...
5
votes
2answers
120 views
Serialize/deserialize objects to and from database concurrently
I have a class which runs as spring bean in the container and its purpose is data persistence. In the overriden method ...
4
votes
1answer
125 views
ConcurrentHashMap Implementation
I have written a simplified version of my own MyConcurrentHashMap. I tried to make use of a Lock[] array for ...
1
vote
1answer
76 views
Implementation of self-updating, asynchronous cache solution of individual (non-bulk) objects
Here I am again; referring to my previous code review request about a self-updating, asynchronous (?) cache.
The previous class takes care of caching operations like "get all users registered in our ...
0
votes
2answers
93 views
Implementation of asynchronous (?), self-refreshing cache of object collection bulk
I'm trying to create a caching solution used in various parts of a clients' application. The resulting code will be open source.
For example, it will be used for caching API queries like "get all ...
2
votes
1answer
50 views
Using goroutines to bruteforce a secret code
For a puzzle I had to brute force a password. I've never used goroutines before, and I don't have much experience in concurrency.
This is the cksum function, which takes an array of the ASCII code ...
4
votes
1answer
308 views
Hybrid Lock Implementation
I have an algorithm that is painfully slow if I use 'pure' mutexes. That's because most of the critical sections are short and far shorter than the work to sleep a thread. However, it is also slower ...
4
votes
1answer
115 views
Multithreaded scoreboard for different levels
For an assignment I had to create a highly multi-threaded scoreboard for a multi level game. So every time a user adds a score if the level doesn't exist, it gets created ad-hoc.
Important point: a ...
3
votes
1answer
75 views
Non-blocking solution to the dining philosophers
This is one of tasks, which I had to do for the recruitment process to be started in some company. Unfortunately they didn't like it so I've decided to share it here for discussion.
Philo5.h
...