Can someone explain this article about enforcing race safety in Scala.
http://www.infoq.com/news/2009/07/scala-actors-race-safe-system ...
http://www.infoq.com/news/2009/07/scala-actors-race-safe-system ...
When I try to create a class instance with a virtual method and pass it to pthread_create, I get a race condition, causing the caller to sometimes call the base method instead of the derived method like it should. After googling pthread vtable race, I found out this is fairly well-known behavior. My question is, what's a good way to ge...
Hello I have some troubles firing and removing events in the right chronicle order. The code below gives the following output: save poster into db, and dispatch event calling service, dispatch event removed = false calling service, dispatch event removed = false calling service, dispatch event removed = true save poster into db, and d...
EDIT: I figured out the answer to the original YUI3 question I posted here, but it led to another one and instead of starting a new thread I thought I'd just add it here. Please scroll down for the new question (it's bolded). Original question: I'm having some issues creating a JavaScript countdown timer inside a YUI definition, my gues...
I'm developing a rails application in which each subdomain has a separate database. And I'm doing something like this. #app/controller/application_controller.rb class ApplicationController < ActionController::Base before_filter :select_database private def select_database MyModel.use_database(request.subdomains.first) end e...
I am writing a python service (pyamf) through which a user can access images. All images are stored on a central server. The python services will be running on satellite machines which have network access to server. The service should work as follows: check locally to see if the file exists, if so, use it. check locally to see if fil...
We have an asynchronous task that performs a potentially long-running calculation for an object. The result is then cached on the object. To prevent multiple tasks from repeating the same work, we added locking with an atomic SQL update: UPDATE objects SET locked = 1 WHERE id = 1234 AND locked = 0 The locking is only for the asynchr...
The naming of this function seems like this is some complicated stuff going on. When exactly does one know that this is the way to go instead of doing something like this: Preparation CRITICAL_SECTION cs; int *p = malloc(sizeof(int)); // Allocation Site InitializeCriticalSection(&cs); // HINT for first Write Thread #1 ...
I have a web application where there is a timer that is constantly counting down. Meanwhile, the client frequently checks with the server to see if more time has been added to the timer. The code looks something like this: function tick() { // This function is called once every second time -= 1; redisplay(time); }; function ...
Hiya. I have a registration page that receives tokens ad parse them and login the user if the parameters apply. Between the time that i checked the token, to the time that i removed the token from the db, another user can use the same token to login. is there a way to make sure that specific range of lines of code will be executed with...
I have implemented a "safe save" operation that goes something like this: Save some data to temporary file A Copy contents of A to final destination B Delete A I have a race condition at step 3 where Mac OS X will occasionally come back with error -47 (fBsyErr) when trying to delete the file using FSDeleteObject. I am completely conf...
An application wants to parse and "execute" a file, and wants to assert the file is executable for security reasons. A moments thought and you realize this initial code has a race condition that makes the security scheme ineffective: import os class ExecutionError (Exception): pass def execute_file(filepath): """Execute seria...
As seen in this question: http://stackoverflow.com/questions/231525/raising-c-events-with-an-extension-method-is-it-bad I'm thinking of using this extension method to safely raise an event: public static void SafeRaise(this EventHandler handler, object sender, EventArgs e) { if (handler != null) handler(sender, e); } But ...
How to prevent a race condition in MySQL database when two connections want to update the same record? For example, connection 1 wants to increase "tries" counter. And the second connection wants to do the same. Both connections SELECT the "tries" count, increase the value and both UPDATE "tries" with the increased value. Suddenly "trie...
Hi there, I'm pulling my hair out with this and I thought I'd see if the greater Java experience of others might be able to shed some light on the problem. There is a large amount of program code I have written, which is itself within a larger project so I can't simply post it. However, I will outline the problem... The issue: My code ...
I am playing around with cuda. At the moment I have a problem. I am testing a large array for particular responses, and when I get the response, I have to copy the data onto another array. For example, my test array of 5 elements looks like this: [ ][ ][v1][ ][ ][v2] Result must look like this: [v1][v2] The problem is how do I calc...
When there are multiple PHP scripts running in parallel, each making an UPDATE query to the same record in the same table repeatedly, is it possible for there to be a 'lag time' before the table is updated with each query? I have basically 5-6 instances of a PHP script running in parallel, having been launched via cron. Each script gets...
When using shared memory, each process may mmap the shared region into a different area of its respective address space. This means that when storing pointers within the shared region, you need to store them as offsets of the start of the shared region. Unfortunately, this complicates use of atomic instructions (e.g. if you're trying to ...
I'm creating a thread that looks for a window. When it finds the window, it overrides its windowproc, and handles WM_COMMAND and WM_CLOSE. Here's the code that looks for the window and subclasses it: public void DetectFileDialogProc() { Window fileDialog = null; // try to find the dialog twice, with a delay of 500 ms each time ...
Are there any race condition issues when using NSNotifications within a single thread? Here is a sample method: - (void) playerToggled: (NSNotification *) notification { if (timerPane.playing && ! timerPane.paused) { [playerPane toggleCurrentPlayer]; [timerPane toggleTimer]; [mainPane playerToggled]; } } The first two ca...