function is `@nogc` yet allocates closures with the GC work around!

workman workman at
Thu Jan 13 07:28:52 UTC 2022

On Wednesday, 12 January 2022 at 14:06:53 UTC, bauss wrote:
> Let me change your analogy and perhaps it will answer your own 
> question.
> step 1) Person A shares a piece of paper with Person B
> step 2) Person B writes something on the piece of paper
> step 3) Person B gives the piece of paper back to Person A
> step 4) Person A reads the piece of paper

Thanks for the example.

I am ask here because I think this cloud be the case:

0) thread A set fiber stack var X = 0;
1) thread A send pointer X to thread B
2) thread B read pointer X, modify the X = 1
3) thread B send finish message to thread A
4) thread A read pointer X, but load X from CPU cache L1, so the 
value still be 0

Thread A & B will never try modify X same time,  but cloud 
read/write value from/to CPU cache.

I am not sure if this cloud be the case here.

More information about the Digitalmars-d mailing list