Locking allows different types of resources to be locked by a transaction.

learn more… | top users | synonyms (1)

1
vote
0answers
31 views

AutoCloseable Lock

Surprisingly, this question has no satisfactory answer. A safe usage of a LockCloseable would be like ...
0
votes
0answers
19 views

Recursive spinlock for C using ASM

My history of C/ASM locks here in codereview: Simple spinlock for C using ASM Simple spinlock for C using ASM, revision #1 (basis for this approach. If this one fails, then so will the one below.) ...
2
votes
0answers
33 views

Simple spinlock for C using ASM, revision #1

Revision #1 for Simple spinlock for C using ASM The code: ...
4
votes
1answer
53 views

Simple spinlock for C using ASM

This is my second attempt to make simple lock using extended assembly. See http://stackoverflow.com/questions/37241553/locks-around-memory-manipulation-via-inline-assembly/37246263 The code: ...
2
votes
1answer
34 views

Thread-safe Bloom Filter in Java

I have tried to implement a Bloom Filter in Java here. https://github.com/srirammanoj/skynet/tree/master/bloomfilter I just wanted to know if my implementation can be called 'thread-safe' , and if ...
1
vote
0answers
24 views

Exclusive row lock

I'm in a situation where I need to manage a kind of FIFO process within a SQL procedure. The procedure is called by a multithreaded windows application. I've created a table which look like this: ...
0
votes
0answers
8 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 ...
3
votes
1answer
68 views

Queuing web service calls

Every call to the web service goes through a custom queuing system. This has a limit that is set to 1. Every call that enters the same time with another call is purged and not handled. Not sure if ...
0
votes
1answer
43 views

Unlocking spreadsheet files quickly - follow-up

I recently posted a program I made to unlock spreadsheet files( see also ), I've taken all of your advice and made it more Ruby like, it has no shell commands in it, and uses ...
4
votes
1answer
62 views

Unlocking spreadsheet files quickly

I've created a program for my job that unlocks spreadsheet files quickly and efficiently. What we use to have to do before this program is we'd have to go into the system, search for the file, kill ...
4
votes
2answers
139 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 ...
2
votes
1answer
61 views

New caching and deferred evaluation strategy

This is a simple wrapper class for a lambda expression, that stores one as Expression and hands it back out either as ...
5
votes
1answer
61 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 ...
5
votes
2answers
1k views

Locking mechanism in C#

I would like you to review the locking mechanism I implement in C# class. Will it be working correctly with many threads? Please don't mind rest of the code because I just try to repair the class ...
6
votes
2answers
115 views

Item-level locks for a large number of items

Background I'm working on a system that records information about a large number of external documents. These documents are organized by "repository". There can be a modest number of repositories ...
0
votes
0answers
118 views

Simple distributed lock manager server based on zmq

I wrote a simple server to distribute locks on a network. It is used in a multi-server environment with a shared home directory to secure non-multiprocessing safe file writing (...
2
votes
1answer
44 views

ReadWriteMap implementation

I had a task to realize ReadWriteMap ...
-2
votes
2answers
576 views

Simple Implementation of a ReentrantLock

An implementation of a ReentrantLock: ...
2
votes
1answer
69 views

Thread-safe removewhere

I'm trying to implement a HashSet that it's accessed from different thread for querying, adding or deleting elements. It doesn't make sense to use a Dictionary for I got several search keys so I won't ...
7
votes
2answers
668 views

Spinlock for C++ kernel (with x86 ASM)

This is some prototype code for a spin-lock for my toy operating system. Bear in mind this means there are no standard library routines to fall back on. It's also for C++11 compilation and will only ...
4
votes
2answers
224 views

Generic object pool class using Spinlock/Monitor

I've written the following object pool class, and because this is my first encounter with synchronization primitives, I need reinsurance from an expert that this code is safe. I've tested it myself ...
4
votes
1answer
1k views

Async distributed locking with StackExchange.Redis [closed]

I have been trying to write an analogy to this approach to distributed locking with two differences: making it asynchronous making it work with StackExchange.Redis rather than AppFabric Cache. My ...
0
votes
1answer
152 views

Thread lock algorithm [closed]

I am trying to make a thread lock for a method so that only one thread can run it at a time. Although this is a well known issue and in C# there is the lock keyword to do it. I was trying to do it on ...
5
votes
1answer
45 views

Simple file locking wrapper command in C

A simple command that wraps another command, locking a file first. It is similar to flock, just simpler. ...
4
votes
3answers
584 views

Using goto to wait on the result of a database query to change

This is a small personal project where most non-sensitive data is distributed to some globally hosted CDN servers, which store the JSON. Now one problem we've seen during testing is a few deadlocks ...
6
votes
1answer
177 views

Deadlock watchdog in a server to defend against poorly written extensions

In the Red5 server we have no control over what implementers do with their applications. As such, we have attempted to implement code that would prevent them from causing bad things to happen. This ...
5
votes
2answers
329 views

Generic Object Pool in C#

I have a limit of 100 sessions (each session held in an object). Many threads will be requesting sessions, and it is very possible that all 100 sessions could be in use at any time. I'm a Junior ...
7
votes
6answers
950 views

Reading a line of text from a socket

I tend to write code, with very few comments, and few line breaks. I'm currently just a student at a University. I've had professors tell me one way or another to comment, but I have a hard time with ...
7
votes
1answer
354 views

Simple, encapsulated C++ logger that can deal with fork/exec situations

Motivation: for whatever reason, some of the available 3rd party logging libraries don't really deal with programs that get fork'ed/exectuted well. For instance, ...
3
votes
2answers
134 views

Locking a remote file

I am using Java to modify remote files in different machines by ssh. At the same time, only one thread is allowed to modify the file in one machine. I implement the logic like this: ...
4
votes
1answer
2k views

Monitoring progress in Parallel.ForEach every minute

I'm using Parallel.ForEach to download 500K URLs and I want to monitor the number of URLs that have been successfully downloaded each minute. ...
10
votes
2answers
305 views

RAII pattern for downgradable ReadWriteLock

The example for downgrading ReentrantReadWriteLock in the Java documentation seems really unsafe when handling exceptions. I tried to write a simple class to ...
5
votes
1answer
137 views

Is my spin-lock implementation correct?

I'm working on a project where a spinlock is more appropriate than a mutex, and after few tries I came up with: ...
3
votes
1answer
38 views

Good approach to raise an exception

I have class House and module Lockable. Locking and unlocking House should reflect the real ...
1
vote
2answers
121 views

SynchronizedArrayList implemented using reader writer synchronization

I am trying to understand the workings of reader writer locks. For the sake of learning, I implemented reader writer synchronization by my own. I implemented ...
7
votes
1answer
1k views

Portable C++ boost::interprocess::mutex

I was looking for long time around to have a portable robust solution for multiprocessing synchronization. Who touche this things know that good solution are boost::iterprocess named sync objects. ...
1
vote
0answers
230 views

Lock a process in PHP

We had a situation where it was necessary that a script only be running in one process at a time. The solution was to make a "LockByProcess" class that checks a database for an existing process, and ...
3
votes
1answer
380 views

Mutualising multi-threaded calls to EJB from Servlet

I have a Servlet that makes an EJB call to a backing server which takes about a second to return some data that changes reasonably regularly. I can't cache the data on the servlet-side, so I have ...
7
votes
2answers
2k views

A simple semaphore in Java

It is a simple semaphore in Java. Although it passes all their tests with flying colors, I'm still not sure it's correct. For example, the last thing I wasn't sure about was ...
3
votes
2answers
734 views

Prevent re-entrant function call in C++

The purpose of this is to prevent a re-entrant function call in a single thread, e.g. prevent the situation where func() calls ...
3
votes
1answer
133 views

Moonshot & `Thread.Abort` - dealing with the fallout

Recently, I encountered an anomaly in the manner by which a worker thread was terminated. It prompted me to do some searching and I realized that I was constructing thread code in a haphazard manner. ...
3
votes
1answer
200 views

Social Share count

I am creating a social sharing counter plugin for my WordPress blog. I want to fetch the counts of number of likes, shares, Facebook comments (I am using Facebook comment box), twitter tweet counts ...
2
votes
1answer
233 views

Testing Promises vs Lock performance

I'm not sure if my lock usage is correct and safe. I wanted to know what will be best approach to deal with situation when one thread have to wait for being initialized by another so I written this ...
5
votes
1answer
220 views

Using CountDownLatch for blocking the reads if writes are happening

I am trying to implement lock by which I want to avoid reads from happening whenever I am doing a write on my three maps. Requirements: Reads block until all three maps have been set for the first ...
4
votes
1answer
172 views

Lock for preventing concurrent access in client data - follow-up

This is a follow-up to: Lock for preventing concurrent access in client data I am trying to implement lock by which I want to avoid reads from happening whenever I am doing a write on my three maps. ...
1
vote
0answers
164 views

Reliability of flock mutex (LOCK_EX|LOCK_NB)

I would like to test reliability of system flock in a multi-threaded and concurrent environment as some suggest that they are not reliable (in comments). Thus I ...
11
votes
2answers
587 views

Thread-safe session manager

Expected behavior of the code below: There will be one static SessionManager accessed by many threads. Multiple calls to ...
6
votes
3answers
150 views

Thread-safe retirement account class

Are these classes properly guarded for thread safety? Do you see any issues with any of the classes? ...
5
votes
1answer
746 views

Operations on files and their locks - code too bulky?

A couple of hours ago I asked a question on Stackoverflow to find out if there is a good way to delete files in a folder only if all files are indeed deletable and I got some good answers that led me ...
2
votes
0answers
446 views

Python app-level document/record locking (eg. for MongoDB)

MongoDB does not provide means to lock a document (like SELECT FOR UPDATE in RDBMS). There is a recommended approach to Isolate Sequence of Operations, which is ...