Questions tagged [concurrency]
In computer science, concurrency is a property of systems in which multiple computations can be performed in overlapping time periods. The computations may be executing on multiple cores in the same chip, preemptively time-shared threads on the same processor, or executed on physically separated processors.
concurrency
23,315
questions
0
votes
1
answer
90
views
Swift 6: Error: Task or actor isolated value cannot be sent
I'm trying to resolve a compilation error: Task or actor isolated value cannot be sent when using Xcode 16.0 beta 3 with Swift 6 and Complete Concurrency enabled. My code:
import SwiftUI
@...
1
vote
1
answer
91
views
Is optimistic locking safe from race condition in case of concurrent transactions? [closed]
When reading about optimistic locks, I have come across examples which use versioning like below
UPDATE table SET column1 = new_value1, version = version + 1 WHERE id = some_id AND version = ...
0
votes
1
answer
36
views
c++ concurrency problem using semaphore: print in order
As an c++ concurrency exercise, I want to print letters A B C in that order, using semaphore. Here's my code:
binary_semaphore sem[] = { binary_semaphore(1), binary_semaphore(0), binary_semaphore(0) };...
0
votes
1
answer
26
views
GRPC Java MAX_CONCURRENT_STREAMS vs maxConcurrentCallsPerConnection
I'm trying to understand the difference between MAX_CONCURRENT_STREAMS and maxConcurrentCallsPerConnection. I read that most servers set MAX_CONCURRENT_STREAMS to 100 as a default whereas ...
1
vote
1
answer
94
views
Passing argument of non-sendable type '(any URLSessionTaskDelegate)?' outside of main actor-isolated context may introduce data races
I am using SwiftUI and I declared the View as @MainActor to resolve some of the concurrency warnings. However, I still get the warning
Passing argument of non-sendable type '(any ...
0
votes
1
answer
35
views
Go channel sometimes not receiving the last value
I'm currently learning go channels, and I'm trying out this piece of code. It creates 10 goroutines which sends a 1000 1s each to a channel. Then another go routine receives it and adds it to a ...
-1
votes
1
answer
50
views
Using AtomicInteger as counter for List [closed]
I am learning multi threading. I have below code which implements round robin algorithm over an CopyOnWriteArrayList. List will always have a fixed number of elements let's suppose 10.
...
0
votes
0
answers
44
views
C++ main thread polling and blocking, termination on signal
I have a main thread which should do some work every N seconds (20 in this case) and wait/block/suspend in-between. However, at the same time, I want the application to stop correctly on a SIGTERM/...
1
vote
1
answer
42
views
Java CopyOnWriteArrayList add element if not exists already
I have an CopyOnWriteArrayList as my code should be thread safe.
List friuts = new CopyOnWriteArrayList<>();
I don't want to have duplicate friuts in list I cannot use Set as I want to have ...
0
votes
0
answers
18
views
Streamlit: keep fragment running while the page loads
I have a Streamlit UI with this code
import streamlit as st
import time
_LOREM_IPSUM = """
Lorem ipsum dolor sit amet, **consectetur adipiscing** elit, sed do eiusmod tempor
incididunt ...
0
votes
1
answer
83
views
ProgressView Not Updating During Data Parsing in SwiftUI
It's hard to reproduce the full code, but I'll try to explain the issue clearly.
I'm trying to display a progress bar view to show the status of parsing some data downloaded online. The function I use ...
0
votes
0
answers
47
views
Request Chunks from the peer in parallel in golang over a tcp connection
I'm building a P2P file transfer system in Go that fetches chunks of data from peers in parallel. While sequential requests work fine, parallel requests using goroutines behave inconsistently, ...
1
vote
0
answers
214
views
Capture of 'self' with non-sendable type in a `@Sendable` closure
I'm working on a NetworkService class in Swift that uses async/await and observes network state changes. I'm converting the code to Swift 6.0 and I'm getting the following error on the line inside ...
-2
votes
0
answers
91
views
Asyncronous function don't run in the correct order [duplicate]
Why is my code not running in the correct order?
I can’t figure out why my code is not executing in the correct order. My downloadData function includes and should run the following three functions in ...
1
vote
2
answers
32
views
Django ORM model 'save' method and race condition / ACID Isolation
if we examine the following code:
class SomeModel(models.Model):
...
def save(self, *args, **kwargs):
self.validate_unique()
super().save()
def validate_unique(self, *args,...