Snapshot/1 use

What happens is snapshot/1 is used with concurrent_and/2?

Something like:

test :-
      concurrent_and(Generator, Test)

Would this cause one ‘snapshot’ for all the threads being executed by concurrent_and/2?

P.S. The only reason I ask, is because I wanted to see if I got a (maybe slight) speedup by using snapshot this way; but for my particular use case it does not work because everything within snapshot/1 is executed as if with once/1; nonetheless the question will help me to better understand the workings of snapshot/1.

As is, no. Snapshots hold for the calling thread only. If a new thread is created it just operates on the global database. It is a good question though. I don’t think it is impossible to inherit the snapshot and thus make child threads use the same base generation. In that case the threads will still be isolated from each other though. That is probably also not what we want. Interesting food for thought, but for now not really high on the priority list, I’d say.

1 Like