concurrency Questions
2
Consider the following, relatively simple Swift program:
import Foundation
func printContext(function: String = #function, line: Int = #line) {
print("At \(function):\(line): Running on \(Th...
Kalgan asked 31/8, 2022 at 20:2
2
Solved
So I am a creating an axios instance that connects to some API like this:
const instance = axios.create(...)
I want to know is there a limit to how many concurrent/parallel requests axios would be ...
Resoluble asked 28/12, 2020 at 23:6
5
Let say I have this code
class Duck{
func walk() async {
//do something
print("walk start")
try? await Task.sleep(nanoseconds: UInt64(2e9))
print("walk end")
}
func q...
Choe asked 23/3, 2022 at 11:43
2
Solved
I've been attempting to take a swing at concurrency in Golang by refactoring one of my command-line utilities over the past few days, but I'm stuck.
Here's the original code (master branch).
Here...
Nickels asked 25/5, 2016 at 14:12
4
Solved
We have come across a strange issue with ConcurrentHashMap, where two threads appears to be calling put(), and then waiting forever inside the method Unsafe.park(). From the outside, it looks like ...
Padauk asked 20/7, 2010 at 17:20
3
Solved
My question is basically a combination of
What is the best way to limit concurrency?
Wait until all promises complete even if some rejected
I'm aware of Promise.allSettled, but I'm failing to fin...
Cheri asked 20/11, 2020 at 14:52
5
Solved
I'm trying to send HTTPS requests as quickly as possible. I know this would have to be concurrent requests due to my goal being 150 to 500+ requests a second. I've searched everywhere, but get no P...
Simonsimona asked 24/11, 2022 at 23:56
3
Solved
What's the best way to add a timeout to an awaiting function?
Example:
/// lets pretend this is in a library that I'm using and I can't mess with the guts of this thing
func fetchSomething() async...
Brood asked 6/12, 2022 at 23:23
1
I am attempting to launch thrust::fill on two different device vectors in parallel on different CUDA streams. However, when I look at the kernel launches in NSight Systems, they appear to be serial...
Aldarcy asked 22/7, 2024 at 18:28
4
Solved
I have a scenario where I have to execute 5 thread asynchronously for the same callable. As far as I understand, there are two options:
1) using submit(Callable)
ExecutorService executorService =...
Englut asked 23/12, 2015 at 17:10
4
Solved
Is it possible to LoadOrStore into a Go sync.Map without creating a new structure every time? If not, what alternatives are available?
The use case here is if I'm using the sync.Map as a cache whe...
Balbinder asked 16/8, 2018 at 20:46
1
I have a server-side application that runs through a large number of image URLs and uploads the images from these URLs to S3.
The files are served over HTTP. I download them using InputStream I get...
Outpost asked 13/2, 2019 at 18:3
4
Solved
Consider, say, a collection of account balances. And then you have a complex function that needs to check the balances of a few different accounts and then adjust the balances of a few different ac...
Huckaback asked 11/11, 2011 at 4:31
4
Solved
In docker we have used deploy: replicas: 3 for our microservice. We have some Cronjob & the problem is the system in running all cronjob is getting called 3 times which is not what we want. We ...
Kieffer asked 30/11, 2021 at 11:9
5
Solved
I have the following Java code:
final Future future = exeService.submit(
new Runnable() {
public void run() {
myObject.doSomething();
}
}
);
future.get();
where exeService is an instance o...
Nipha asked 6/4, 2010 at 15:12
5
Solved
Ok, so I know the first answer / comment here will be "use one ExecutorService and use invokeAll". However, there is a good reason (which I will not bore people with) for us keeping the thread pool...
Flavory asked 1/11, 2012 at 18:55
2
I have noticed that the start(queue:) method in NWPathMonitor requires a queue of type DispatchQueue. Is there a way to implement this using Swift Modern Concurrency, probably using AsyncStream?
Us...
Quirita asked 27/10, 2022 at 11:33
3
Solved
I need two threads to progress in a "tick tock" pattern. When implmented with a semaphore this looks fine:
Semaphore tick_sem(1);
Semaphore tock_sem(0);
void ticker( void )
{
while( true )
{
P...
Bet asked 23/7, 2011 at 23:51
2
Solved
I read about AsyncLocal<T> from the MSDN documentation, but one point is still not clear for me.
I'm working on something like a context-bound caching/memoization, which has the simple purpo...
Sulfuric asked 21/4, 2020 at 10:39
2
Solved
In The Art of Multiprocessor Programming, rev. 1st Ed., in Ch. 2, Excercise 9 is as follows (paraphrased):
Define r-bounded waiting for a mutex algorithm to mean that DAj ➝ DBk ⇒ CS...
Coop asked 24/5, 2014 at 18:12
17
Solved
I want to create a ThreadPoolExecutor such that when it has reached its maximum size and the queue is full, the submit() method blocks when trying to add new tasks. Do I need to implement a custom ...
Varityper asked 4/1, 2010 at 17:59
11
I am trying to execute lots of tasks using a ThreadPoolExecutor. Below is a hypothetical example:
def workQueue = new ArrayBlockingQueue<Runnable>(3, false)
def threadPoolExecutor = new Thre...
Surra asked 10/8, 2010 at 4:24
9
According to the Go blog,
Maps are not safe for concurrent use: it's not defined what happens when you read and write to them simultaneously. If you need to read from and write to a map from con...
Braille asked 22/3, 2016 at 23:35
8
Is there such a thing as an atomic test-and-set, semaphore, or lock in Javascript?
I have javascript invoking async background processes via a custom protocol (the background process literally run...
Mara asked 17/2, 2009 at 0:51
3
Solved
Can I post a notification in a given queue and receive it on another? I want to use notifications to communicate different queues, but I'm not sure if this is safe...
Jasik asked 12/4, 2013 at 10:1
1 Next >
© 2022 - 2025 — McMap. All rights reserved.