concurrency

Is there a way to use Bluebird's Promise.each concurrently?

陌路散爱 提交于 2019-12-24 01:19:26
问题 Bluebird has a nice function called Promise.map that lets you pass in an extra argument for the amount of concurrent operations. e.g. yield Promise.map arrayOfThings, coroutine (thing) -> newThing = yield thing.operate() database.set newThing , concurrency: 500 However, Promise.map will keep an array of whatever database.set newThing returns in memory for all of arrayOfThings . I'd rather not store all of that in memory as it bogs down my server. Optimally, I would want to replace Promise.map

Need of volatile keyword in case of DCL

为君一笑 提交于 2019-12-24 00:57:57
问题 I was just reading concurrency in practice. I came to know it is necessary to use volatile keyword in double checked locking mechanism for field otherwise thread can read stale value of not null object. Because it is a possibility of reordering instruction without use of volatile keyword. Because of that object reference could be assigned to resource variable before calling constructor. so thread could see partially constructed object. I have a question regarding that. I assume synchronized

Does OpenCL allow concurrent writes to same memory address?

强颜欢笑 提交于 2019-12-24 00:49:38
问题 Is two (or more) different threads allowed to write to the same memory location in global space in OpenCL? The write is always changing a uchar from 0 to 1 so the outcome should be predictable, but I'm getting erratic results in my program, so I'm wondering if the reason can be that some of the writes fail. Could it help to declare the buffer write-only and copy it to a read-only buffer afterwards? 回答1: Did you try to use the cl_khr_global_int32_base_atomics extension and atom_inc intrinsic

Worker verticles not processing requests in parallel

穿精又带淫゛_ 提交于 2019-12-24 00:22:44
问题 I am trying to scale an application which does a blocking call to an external application to fetch some data (Request and response order does not matter) Since, its a blocking call as described in the vertx docs I am using worker verticle with worker pool set to 5 and I have deployed 5 instances of the worker verticle When I submit multiple queries(when I tested I just fired 3 queries) even though my verticle is defined as worker with multiple instances with sufficient worker threads to

calling an api concurrently in python

人盡茶涼 提交于 2019-12-24 00:15:03
问题 I need to talk to an api to get information about teams. Each team has a unique id. I call the api with that id, and I get a list of players on each team (list of dicts). One of the keys for a player is another id that I can use to get more information about that player. I can bundle all these player_ids and make a call to the api to get all the additional information for each player in one api call. My question is this: I expect the number of teams to grow, it could be quite large. Also, the

using conditional logic : check if record exists; if it does, update it, if not, create it

不羁岁月 提交于 2019-12-23 23:16:41
问题 I asked this last night, and got information on merging (which is unavailable in postgresql). I'm willing to try the workaround suggested But I'm just trying to understand why it can't be done with conditional logic. I've clarified the question a bit, so maybe this will be easier to understand. I have a query that inserts data into a table. But it is creating a new record every time. Is there a way I can check if the row is there first, then if it is, UPDATE , and if it isn't INSERT ? $user =

what's the purpose of compiler barrier?

独自空忆成欢 提交于 2019-12-23 23:07:43
问题 The following is excerpted from Concurrent Programming on windows, Chapter 10 Page 528~529, a c++ template Double check implementation T getValue(){ if (!m_pValue){ EnterCriticalSection(&m_crst); if (! m_pValue){ T pValue = m_pFactory(); _WriteBarrier(); m_pValue = pValue; } LeaveCriticalSection(&m_crst); } _ReadBarrier(); return m_pValue; } As the author state: A _WriteBarrier is found after instantiating the object, but before writing a pointer to it in the m_pValue field. That's required

Acquisition of turn based concurrency lock for actor '{actorName}' timed out after {time}

无人久伴 提交于 2019-12-23 22:02:25
问题 I have service which creates Actors of some type by some name: var storer = this.serviceClient.Create<IStorer>(new ActorId(agencyToProcess.Name)); and then I call Actor's method. await storer.StoreStatusesAsync().ConfigureAwait(false); On this call I receive error : System.AggregateException: One or more errors occurred. ---> Microsoft.ServiceFabric.Actors.ActorConcurrencyLockTimeoutException: Acquisition of turn based concurrency lock for actor 'actorName' timed out after 00:01:13.6480000.

What is the absolute fastest way to implement a concurrent queue with ONLY one consumer and one producer?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 21:55:53
问题 java.util.concurrent.ConcurrentLinkedQueue comes to mind, but is it really optimum for this two-thread scenario? I am looking for the minimum latency possible on both sides (producer and consumer). If the queue is empty you can immediately return null AND if the queue is full you can immediately discard the entry you are offering. Does ConcurrentLinkedQueue use super fast and light locks (AtomicBoolean) ? Has anyone benchmarked ConcurrentLinkedQueue or knows about the ultimate fastest way of

one java memoryFlushing volatile: A good programdesign?

自作多情 提交于 2019-12-23 21:49:54
问题 its a related question to this one: java: using volatile at one variable VS each variable i have one or more different objects. i want to change some state in it and then i want to make that state visible to other threads. For performance reasons i dont want to make each member variable in that objects volatile. And sometimes i want to use these objects in a single thread application. So in that case the volatile would be also bad. So i had the following: //these following mehtods change some