race-condition

Is there any race condition below?

独自空忆成欢 提交于 2019-12-11 13:16:32
问题 I have below code in my express server (have cut it down for brevity). I have a common object which I'm adding/modifying/reading in three different restful end points. Since all http requests in nodejs are asynchronous, I could get both put and get request at the same time . So although PUT happened but lets say status is not updated, my GET could get a slightly stale response? From what I understand, and my testing shows that there is no race condition here. Because updating results object

Multiple Sequential Async JavaScript Functions

橙三吉。 提交于 2019-12-11 11:09:04
问题 Let's say I have a function that looks like this: var foo = function(callback) { var final = {}; asyncFuncOne(function(x) { final.x = x; }); asyncFuncTwo(function(y) { final.y = y; }); callback(final); }); Obviously, this doesn't do what I want it to do (call callback on final when it has both x and y). I have several questions: Is there a way to do what I want it to do without nesting everything? Does the current form introduce a race condition? Are both async functions accessing the same

How do I consistently increase a counter cache column?

元气小坏坏 提交于 2019-12-11 08:13:41
问题 Lets say I have a counter cache that needs to to be incremented on every page load. Say I have 10 web instances. How do I consistently increase a counter cache column? Consistency is easy with one web instance. but with several instances running, A race conditions may occur. Here is a quick explanation. Let's say my counter cache column is called foo_counts and its starting value is 0. If 2 web instance are loaded at the same time, both realize the count as 0. When it comes time to increase

Is there really a race condition in this multi-threaded java code?

只愿长相守 提交于 2019-12-11 05:44:58
问题 I saw a snippet of code in this question which I could not understand (most probably due to the fact am a beginner in this area). The question talks about "an obvious race condition where sometimes the producer will finish, signal it, and the ConsumerWorkers will stop BEFORE consuming everything in the queue." In my understanding, "isRunning" will be set on the consumers only after the producer decides not to add anymore items in the queue. So, if a consumer thread sees isRunning as FALSE AND

How to Select Head and Tail at the same time in Reactive Extensions

强颜欢笑 提交于 2019-12-11 04:03:58
问题 I would like to create the following combinator public static IObservable<U> HeadTailSelect<T, U> (this IObservable<T> source, Func<T, IObservable<T>, U> fn) { } The selector method should be passed the current event and an observable to all future events, the tail. It must be guaranteed that upon subscribing to the tail any time in the future the first received event will be the very next one that was received after the head. I'm aware that this will require some buffering but I'm not quite

Some MySql queries with PHP condition

放肆的年华 提交于 2019-12-11 03:21:53
问题 background: I want to match users in a PHP-Webapp. When an user enters a specific page, he will be put into a virtual pool. The pool is realised as the following MySql table: "search-table": id|userId|parameter Every user is checking, if there is annother user in that table, who is ready to match.(ready to match=same parameter). The check is done by an AJAX-Request to my PHP controller every x-seconds. (the AJAX-Request ist repeated until a match was found, or the user leaves). If this query

Possible race conditions when creating and updating a struct in the same request - coldfusion

女生的网名这么多〃 提交于 2019-12-11 02:39:30
问题 About a year ago I asked a question about errors I was getting in an app, that indicated a possible race condition: Possible race condition creating Structs in ColdFusion A year on, I'm still having issues with this and other apps where the same technique is employed and it seems that frankly, you cannot create and update a struct reliably in the same request. This of course seems ludicrous, so I must be doing something wrong - but I'd appreciate some help. Here's an explanation of what's

Conditional wait with pthreads

我的梦境 提交于 2019-12-11 01:58:51
问题 I seem to be running in to a possible deadlock with a pthreads conditional variable. Here is the code thread function(){ for (condition){ do work /* should the thread continue? */ if (exit == 1){ break; /* exit for */ } } /* end for */ pthread_mutex_lock(&mtxExit); exit = 0; pthread_cond_signal(&condVar); pthread_mutex_unlock(&mtxExit); } The main function is as follows: function main(){ if (thread is still active){ pthread_mutex_lock(&mtxExit); exit = 1; pthread_mutex_unlock(&mtxExit); } /*

Race Condition in CUDA programs

戏子无情 提交于 2019-12-11 01:36:51
问题 I have two pieces of code. One written in C and the corresponding operation written in CUDA. Please help me understand how __syncthreads() works in context of the following programs. As per my understanding, __syncthreads() ensures synchronization of threads limited to one block. C program : { for(i=1;i<10000;i++) { t=a[i]+b[i]; a[i-1]=t; } } ` The equivalent CUDA program : ` __global__ void kernel0(int *b, int *a, int *t, int N) { int b0=blockIdx.x; int t0=threadIdx.x; int tid=b0*blockDim.x

Jasmine.js: Race Conditions when using “runs”

血红的双手。 提交于 2019-12-10 22:30:29
问题 I have noticed a strange behaviour when testing my code with jasmine. One test fails when executed together with the other tests in my spec. When called alone the test passes. The test asserts the script A.js that depends on script B.js which offers the method "Create". I create inside the test a spy for the "Create" and invoke script A.js (A.init) that will load some data (loadData with returns again a promise) and then call the "Create" method 5 times (once the loadData-promise is resolved)