How about using what’s already used in a few of KM’s actions: a leading “^” means it’s a regex?
By the way, I like your way of doing this better than what I was thinking of.
I just posted a feature request for Peter to add Read-Write locks. These would be perfect for handling the concurrency issue.
It would mean adding a read-lock to the beginning of all affected macros, but there’s almost no overhead. The cleanup macro would try to acquire a write-lock.
Macros that get the read-lock would not hinder each other. It’s only the write-lock that blocks anything.
So when the cleanup macro tries to get the write-lock, it would block until no macros held a read-lock. Once it got the write-lock, any other macros would block trying to get the read-lock, until the cleanup macro was done.
I hope that makes sense. I never tried to explain it before - I know how it works, but putting it in words isn’t easy!