From Schelte on the chat:
apn, I don't understand how/when to use promise::async_fulfill. I used it and then got an error later, when the async code finished. I think the problem was that another fulfill was done with the result of the async code, but the promise had already disappeared by then.
2:36
Of course, just returning the desired value turned out to be the easy solution.
2:37
But the existence of promise::async_fulfill and promise::async_reject confused me.
4:34 PM
@schelte
, speaking from somewhat hazy memory (this is what happens when stuff is not documented clearly enough, the author also forgets!) async_fulfill allows you to fulfill the promise while continuing the current thread of execution.
APP 4:38 PM
You are only supposed to use it from within async code. So how do you stop the async call from trying to fulfill the promise again on termination? Maybe that should be changed to safe_fulfill?
4:40 PM
I thought the async call already did that. I'd have to go source dive, but see async-fulfill-0 test. Is that the pattern you are looking for?
4:41
Of course, it could always be a bug!
4:43
Hmm...you may be right but how does that test not fail then. Need to take a deeper look.
APP 4:44 PM
The test doesn't enter the event loop?
4:46
It's not a problem for me at this moment. It's just something I ran into and thought you might want to know.
4:47 PM
Ok. I'll note it for whenever I work on my extensions next. I fear it will not be for a long long while :-(
Moved to https://github.com/apnadkarni/tcl-promise/issues/1