I've used a Mutex<bool>
before for a similar purpose. Something like this
use tokio::sync::Mutex;
static INITIALISED: Mutex<bool> = Mutex::const_new(false);
async fn reset_and_seed_db() {
let mut initialised = INITIALISED.lock().await;
if *initialised {
return;
}
// do stuff
*initialised = true;
}
Whichever function happens to lock INITIALISED
first will run the function while the others wait, and after its done the others will just check the bool, see that it's set to true and continue on with the test.