-
Notifications
You must be signed in to change notification settings - Fork 0
Concept
Vladislav edited this page Oct 4, 2017
·
1 revision
- Promise - 'front' header only class with mass of template methods to cover maximum functionality without any transpilation.
- PromisePrivate - middle header only class with core functionality, i.e. managing then/finish/bind operations in low-level manner.
- AsyncHandler - low-level platform/library specific code with shared (preferably) library interface for operate inter-thread/-coroutine communications to produce async processing of promise events.
t.then(cb) : nt
-> nt.new
nt.bind(t)
-> nt.handleThen(cb)
t.finish(r)
-> t.handleFinish(r)
t.bind(p)
t.i += p;
-> p.handleBind(t)
t.handleBind(o)
t.o = o;
if t.finished
t.o.finish( t.result )
t.handleFinish(r)
t._recheckInners(r)
t._callThen()
t.handleThen(cb)
t.cb = cb
t._callThen()
t._callThen()
if t.finished && t.cb
t.o.finish( t.cb(t.result) )
t._recheckInners(r)
t.result = r
t.finished = true;
> asyncWork() : 1
-> 1.new
> 1.then(here) : 2
-> 2.new
2.bind(1)
-> 1.handleBind()
-> 2.handleThen()
> 2.then(there) : 3
-> 3.new
3.bind(2)
-> 2.handleBind()
-> 3.handleThen()
> 3.then(there) : 4
-> 4.new
4.bind(3)
-> 3.handleBind()
-> 4.handleThen()
> asyncFinish()
1.finish()
-> 1.handleFinish()
1._callThen()
2.handleFinish() <- 2.finish()
2._callThen()
3.finish() -> 3.handleFinish()
3._callThen()
4.finish()
-> 4.handleFinish()
4._callThen()