On Thursday, 22 July 2021 at 16:39:45 UTC, Steven Schveighoffer
wrote:
On 7/22/21 1:46 AM, seany wrote:
[...]
Correct. You must synchronize on ii.
[...]
This isn't valid code, because you can't append to an integer.
Though I think I know what you meant. Is it thread-safe
(assuming the
On 7/22/21 1:46 AM, seany wrote:
Consider :
int [] ii;
foreach(i,dummy; parallel(somearray)) {
ii ~= somefunc(dummy);
}
This is not safe, because all threads are accessing the same array and
trying to add values and leading to collision.
Correct. You must synchronize
On Thursday, 22 July 2021 at 09:02:56 UTC, jfondren wrote:
On Thursday, 22 July 2021 at 07:51:04 UTC, seany wrote:
OK.
Sorry for the bad question : what if i pregenerate every
possible key, and fill the associative array where each such
key contains some invalid number, say -1 ?
You mean
On Thursday, 22 July 2021 at 07:51:04 UTC, seany wrote:
OK.
Sorry for the bad question : what if i pregenerate every
possible key, and fill the associative array where each such
key contains some invalid number, say -1 ?
You mean where each value contains some invalid number, and the
AA's
On Thursday, 22 July 2021 at 06:47:52 UTC, Ali Çehreli wrote:
But even if it did, we wouldn't want synchronized blocks in
parallelization because a synchronized block would run a single
thread at a time and nothing would be running in parallel
anymore.
But it only affects the block, the
On Thursday, 22 July 2021 at 07:27:52 UTC, jfondren wrote:
On Thursday, 22 July 2021 at 07:23:36 UTC, seany wrote:
On Thursday, 22 July 2021 at 05:53:01 UTC, jfondren wrote:
No. Consider
https://programming.guide/hash-tables-open-vs-closed-addressing.html
The page says :
A key is always
On Thursday, 22 July 2021 at 07:23:36 UTC, seany wrote:
On Thursday, 22 July 2021 at 05:53:01 UTC, jfondren wrote:
No. Consider
https://programming.guide/hash-tables-open-vs-closed-addressing.html
The page says :
A key is always stored in the bucket it's hashed to.
What if my keys are
On Thursday, 22 July 2021 at 05:53:01 UTC, jfondren wrote:
No. Consider
https://programming.guide/hash-tables-open-vs-closed-addressing.html
The page says :
A key is always stored in the bucket it's hashed to.
What if my keys are always unique?
On 7/21/21 11:01 PM, frame wrote:
> This is another parallel foreach body conversion question.
> Isn't the compiler clever enough to put a synchronized block here?
parallel is a *function* (not a D feature). So, the compiler might have
to analyze the entire code to suspect race conditions. No,
On Thursday, 22 July 2021 at 05:46:25 UTC, seany wrote:
But what about this :
int [ string ] ii;
ii.length = somearray.length;
foreach(i,dummy; parallel(somearray)) {
string j = generateUniqueString(i);
ii[j] ~= somefunc(dummy);
}
Is this also guaranteed thread
On Thursday, 22 July 2021 at 05:53:01 UTC, jfondren wrote:
On Thursday, 22 July 2021 at 05:46:25 UTC, seany wrote:
But what about this :
int [ string ] ii;
ii.length = somearray.length;
foreach(i,dummy; parallel(somearray)) {
string j = generateUniqueString(i);
ii[j] ~=
Consider :
int [] ii;
foreach(i,dummy; parallel(somearray)) {
ii ~= somefunc(dummy);
}
This is not safe, because all threads are accessing the same
array and trying to add values and leading to collision.
But :
int [] ii;
ii.length = somearray.length;
12 matches
Mail list logo