I've got a web application that controls which web applications get served traffic from our load balancer. The web application runs on each individual server.
It keeps track of the "in or out" state for each application in an object in the ASP.NET application state, and the object is serialized to a file on the disk whenever the state i...
If I define a local variable instance of a class halfway down my function without using a pointer and new, does the constructor get called on entering the function or where it is defined?
If I define another instance of a class globally within the file does that constructor get called when executable is first loaded? What if multiple th...
If the locks make sure only one thread accesses the locked data at a time, then what controls access to the locking functions?
I thought that boost::mutex::scoped_lock should be at the beginning of each of my functions so the local variables don't get modified unexpectedly by another thread, is that correct? What if two threads are tryi...
I was trying to restore a backup but I kept getting OS error 32 - cannot delete because in use.
Couldn't figure out what was locking the data and log files - so I rebooted the machine, stopped the service but still no luck.
Then I deleted the DB but data and log files are still there.
Rebooted again - tried to delete them but looks li...
Does anyone know of an existing ruby implementation of a read/write lock - http://en.wikipedia.org/wiki/Readers-writer_lock?
Preferably this would be in a popular library or some other implementation that's been used by enough people that it's fairly bulletproof at this point.
...
I have some code that will be accessed from two threads:
class Timer{
public:
void Start(){
start_ = clock_->GetCurrentTime();
running_ = true;
}
void Read(){
if(running_){
time_duration remaining = clock_->GetCurrentTime() - start_;
Actions(remaining)
}
}
private:
void Actions...
I have a stored procedure that manipulates an integer table field (which represents a sequence number) based on some criteria - the criteria can reset the field back to zero. In a multiuser environment there is a possibility that the field may be referenced by 1 user before it is updated by another user so I would like to prevent this by...
Follow up to: How to safely update a file that has many readers and one writer?
In my previous questions, I figured out that you can use FileChannel's lock to ensure an ordering on reads and writes.
But how do you handle the case if the writer fails mid-write (say the JVM crashes)? This basic algorithm would look like,
WRITER:
lock...
I would like to find a generic way of preventing to save an object if it is saved after I checked it out.
We can assume the object has a timestamp field that contains last modification time. If I had checked out (visited a view using a ModelForm for instance) at t1 and the object is saved again at t2, given t2 > t1 I shouldn't be able t...
Hi,
I just came across the question - is the access of an object safely possible across threads in C#.
E.g. with the code
//Somewhere long ago
MyClass myVar = new MyClass("First Instance");
//Then later, happening at the same time
//In thread one
myVar = new MyClass("Second Instance");
//In thread two
myVar.PrintName();
I don't ca...
How would I validate that a jpg file is a valid image file. We are having files written to a directory using FTP, but we seem to be picking up the file before it has finished writing it, creating invalid images. I need to be able to identify when it is no longer being written to. Any ideas?
...
How to write a Reader/Writer lock with timeout, using conditional variables in C/C++?
...
Here's the scenario: I have a multi threaded java web application which is running inside a servlet container.
The application is deployed multiple times inside the servlet container. There are multiple servlet containers
running on different servers.
Perhaps this graph makes it clear:
server1
+- servlet container
+- application1
...
i try to put a lock to a static string object to access to cache,, the lock() block executes in my local,but whenever i deploy it to the server, it locks forever. i write every single step to event log to see the process and lock(object) just causes the deadlock on the server. The command right after lock() is never executed as the i do...
Hi all. I'm working on maintenance of a .NET project, and I'm having some troubles which I'll gladly share with you guys =)
The problem code:
if( evilDict.Count < 1 )
{
foreach (Item item in GetAnotherDict())
if (!evilDict.containsKey(item.name.ToLower().Trim()))
evilDict.add(item.name.ToLower().Trim(), item.ID)...
Suppose I have the following code:
public class SomeClass()
{
private readonly object _lock = new object();
public void SomeMethodA()
{
lock (_lock)
{
SomeHelperMethod();
//do something that requires lock on _lock
}
}
public void SomeMethodB()
{
lock (_lock)
{
SomeHel...
I want to implement an atomic transaction like the following:
BEGIN TRAN A
SELECT id
FROM Inventory
WITH (???)
WHERE material_id = 25 AND quantity > 10
/*
Process some things using the inventory record and
eventually write some updates that are dependent on the fact that
that specific inventory record had sufficient quantity (greater ...
I have two tables (well, two relevant for this question) :
Bets (holds the bets; Columns : Id, , MessagesPosted, )
Bets_Messages (holds the bets' forum messages; Columns : Id, BetId, )
When I insert a new BetMessage in Bets_Messages I want to update (increment to be precise) the corresponding field in Bets.
In pure T-SQL that would be...
A DBA that my company hired to troubleshoot deadlock issues just told me that our OLTP databases locking problems will improve if we set the transaction level to READ COMMITTED from READ UNCOMMITTED.
Isn't that just 100% false? READ COMMITTED will cause more locks, correct?
More Details:
Our data is very "siloed" and user specific....
Hi all,
This is a detail question for C#.
Suppose I've got a class with an object, and that object is protected by a lock:
Object mLock = new Object();
MyObject property;
public MyObject MyProperty {
get {
return property;
}
set {
property = value;
}
}
I want a polling thread to be able to query ...