Your code is wrong in many ways that, to me it's not clear what you are trying to do. Try explaining it with words with a self-contained (pseudo-)code maybe.
Check the docs also (which explicitly mentions that it is the function that yields returns the function state, on which you can call resume, not the other way around).
Also, in case you're going to use it with signals, current implementation of yield doesn't work as advertised in the docs: you can yield only from a top-level function. See this issue for details.