Population Genetics - an exercise converting a C++ program to Rust


#1

People,

I have in mind a role for Rust in a potentially large future project but I have not got enough information yet to decide whether using Rust is appropriate or not:

However, it occurred to me that rewriting an old C++ project might be a good test exercise for me to get some more Rust familiarity and I can see how to do a basic prototype but I have an arising question.

The quick description is:

Simulating an i by j grid of sub-populations (demes) for k generations where a proc needs to be spawned for each ij deme. After all the procs finish running, there is some processing on the whole grid (eg selection, migration between demes etc) before the next generation starts and the whole process repeats. I can see that it is easy to spawn ij procs for each generation but I presume there is a convenient way of telling when all these procs have finished running before doing the whole of grid processing part of the simulation?

Thanks,

Phil.


Frustration growing
#2

As always, It Depends. You can do this a number of ways. One common way is to just join on all the sub-threads, and wait until they’re all joined to continue. join() blocks until the thread joins, so this is pretty easy. Another way is to use channels.