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

learn more… | top users | synonyms

2
votes
4answers
160 views

Designing a better logger class

Could you please critisize the logger class below? Can it be used in a multi threaded web environment? If not how can I improve it? Is there anything wrong with locking in WriteToLog method or ...
0
votes
3answers
65 views

How to correctly get a IDisposeable when you need to lock the factory?

If I need to create a IDisposeable object from a factory, but if the factory object is not thread safe and requires me to lock on it is this the correct pattern to use? public void ...
4
votes
2answers
114 views

Getting a decryptor object

I need to lock on my AesManaged instance _Aes to call CreateDecryptor() however the CreateDecryptor() method is not thread safe and this function could be called by multiple threads. Is this the ...
7
votes
2answers
164 views

Synced/Atomic access

Forward I would love any comments you have, any ideas, any flaws you can find, and any suggestions you might have regarding the code below. If this is similar to other implementations, I would love ...
2
votes
1answer
279 views

Resource Pool implementation with ReentrantLock and Condition

The Resource Pool is similar to the implementation of a semaphore. It takes the class type of the resource and number of resource pools associated with it as the constructor parameters. There is a ...
1
vote
2answers
369 views

Multithreading concepts with Producer Consumer

I just wanted to confirm if this example I created would qualify as a good example of a multithreaded producer consumer. I would like any review changes on improving this example. I found that static ...
3
votes
4answers
268 views

Java Non Reentrant Lock Implementation

I have implemented a Non Reentrant Lock. I want to know if this has any mistakes, race conditions etc. I am aware of the fact that existing libraries have to be used (instead of writing our own), but ...
5
votes
0answers
74 views

Concurrency limit map in Go

Please someone who knows locks, mutexes, and Go, review the following code. Task: per host concurrency limits for web crawler (map[string]Semaphore). I considered chan struct{} (chan bool) approach, ...
3
votes
1answer
121 views

Improving handling of data structure used in parallel

I have a class extending the Dictionary class. This class is used for storing some information (modeled in CustomClass) and accessing it through an integer ID. To extend this class I have added a ...
7
votes
3answers
436 views

Force locking for thread-safety

After reading Herb Sutter's Associate Mutexes with Data to Prevent Races, I found that my solution was superior in several aspects, least important first: The code is cleaner, without macros No ...
3
votes
4answers
165 views

Configurable synchronization approach in Java

I am interested in the community opinion about the following approach for the synchronization. Generally it is based on the idea to have a configurable way to apply locking on some logic parts. Any ...
1
vote
1answer
467 views

ReentrantLock with priorities for waiting threads

I am trying to have a ReentrantLock with another way to determinate which thread will have the lock in the waiting queue. ReentrantLock implementation manages a Fair/Unfair policy, that's not what I ...
4
votes
2answers
2k views

Did I need to use lock to ensure that Queue.Dequeue is Thread Safe in this case on .NET 2.0?

Is this ok? I am using C# and .NET 2.0 I have this Queue declared in my class : static private Queue<SignerDocument> QUEUE = new Queue<SignerDocument>(); I fill this Queue with some ...
1
vote
1answer
224 views

Read-write lock implementation for Ruby, new version

I recently discovered that there is no free read-write lock implementation for Ruby available on the Internet, so I built one myself. The intention is to keep it posted on GitHub indefinitely for the ...
11
votes
2answers
453 views

Lock-free cache oblivious n-body algorithm

I'm currently looking at, from a rather high level, the parallelization of the gravity calculation in an N-body simulation for approximating a solution to the N-body problem. The simple form of the ...
4
votes
0answers
937 views

“Fast” Read/Write Lock

I need a Read-Write lock that is fast and generally portable on Windows machines (including XP, otherwise I'd just use the SRWLock that was introduced with Vista). I've written this custom ...
3
votes
2answers
85 views

Review a newbie's pthread code

I'm a pthread newbie and I've been giving myself a challenge: I want to have a resource that multiple threads can access at the same time as read. However, if a thread wants to write, then this need ...
3
votes
1answer
276 views

Single word CAS tagged pointer for algorithms susceptible to the ABA problem

I've been looking for a solution to the ABA problem for a lock-free stack. Searching the Web revealed patented and complicated hazard pointers and tagged pointers using double compare-and-swap (DCAS, ...
0
votes
1answer
87 views

Security concerns with locking files

I'm writing a perl script which reads logs from a file and looks for matches from another file before sending the matches off by email. The problem is, I'm dealing with files which could be changed (a ...
4
votes
2answers
4k views

Using Timer with Backgroundworker to ensure the doWork method is called

I have a windows forms application in which a backgroundworker is called again and again. I need to avoid concurrent access of the code in dowork method for the backgroundWorker; but also need to ...
5
votes
4answers
560 views

Associating a lock/mutex with the data it protects

I've recently come across some areas of code in our solution that have a few thread-safety problems. Thread-safety is a minefield at best so I thought I'd have an attempt at writing a few little ...
6
votes
1answer
697 views

Waiting for a lock to release with ManualResetEvent and Quartz

Follow-up to: Waiting for a lock to release with Thread.Sleep()? I've found the time I tried to rewrite my WaitForLock-Method to utilize the Quartz.NET Scheduler which I've been using for some ...
8
votes
3answers
1k views

Waiting for a lock to release with Thread.Sleep()?

There's a follow-up: Waiting for a lock to release with ManualResetEvent and Quartz. I've written a simple Lock-Mechanism which is saving the states of the locks in a database. Now I need to wait ...
4
votes
1answer
1k views

C++ critical section with timeout

NOTE: My implementation is based on codeproject article by Vladislav Gelfer. Based on valdok's codes, I rewrote the critical section class. The difference is that my implementation integrated ...
2
votes
2answers
387 views

Composable Locks using LINQ. Can anyone see any problem with this ?

I was playing around with LINQ and I came up with the following idea for composing locks taking advantage of C# Monadic syntax. It seems too simple, so I thought let me post it on StackExchange and ...
4
votes
1answer
299 views

Is this waiting code with timeout ok?

public boolean connectedOnGameServer = false; public final Object conGameServerMonitor = new Object(); public void connectedToGameServer() { synchronized (conGameServerMonitor) { ...
22
votes
5answers
3k views

Is this (Lock-Free) Queue Implementation Thread-Safe?

I was trying to create a lock-free queue implementation in Java, mainly for personal learning. The queue should be a general one, allowing any number of readers and/or writers concurrently. Would you ...