Trying to make a async building system with +jobs in latest vim, I find 
sometimes 'exit_cb' in invoked after 'close_cb' but sometimes 'close_cb' is 
invoked after 'exit_cb':

That's what I done in my plugin:
1. output text to quickfix window when 'callback' / 'out_cb' / 'err_cb' happen
2. output "(close)" to quickfix window when 'close_cb' happen, and flush all 
the text in channel to quickfix.
3. output "[Finished in xx seconds]" to quickfix when 'exit_cb' happen and 
clean my job state.

Sometimes I get this in quickfix:
hello.c:1: xxxxx         -> from 'callback'
hello.c:2: xxxxx         -> from 'callback'
hello.c:3: xxxxx         -> from 'callback'
hello.c:4: xxxxx         -> from 'callback'
(close)                       -> from 'close_cb'
[Finished in 2 seconds] -> from 'exit_cb'

but sometimes I get this:
hello.c:1: xxxxx         -> from 'callback'
hello.c:2: xxxxx         -> from 'callback'
hello.c:3: xxxxx         -> from 'callback'
[Finished in 2 seconds] -> from 'exit_cb'
hello.c:4: xxxxx         -> from 'callback'
(close)                       -> from 'close_cb'

I just can't figure out which one will happened at last ? 'close_cb' or 
'exit_cb' ? 
and which one should I rely to do the clean stuff ?

If I reset my building state in 'close_cb' (reset variables and unlet job 
object and output 'finished') 
when 'exit_cb' comes after 'close_cb' the environment is already destroyed.

And if I reset my building state in 'exit_cb' when 'close_cb' comes after 
'exit_cb' the environment is already destroyed too.

I have created a similar plugin for atom text editor ( 
https://atom.io/packages/atom-shell-commands ) with javascript by using a 
'child_process' module in node.js. The "process exit callback" in always 
invoked after all pipe callbacks, so I can simply
delete the child-process object and do the destruction things in "process exit 
callback" without worry about any other callbacks will come after that.

Is this possible to guarantee that 'exit_cb' will alway be invoked after all 
other callbacks (close_cb/out_cb/err_cb etc) ?
If so, it will be much easier for me to write my async building plugin for vim.




[email protected]

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui