skywind3000 wrote:

> Using jobs to write an async building system, I can not find a
> callback which I can relay on it to clean my build state (unlet job
> object and output 'finished' to quickfix window):
> 
> Sometimes 'close_cb' is invoked after 'exit_cb' and sometimes
> 'exit_cb' is invoked after close_cb and even 'callback'will happen
> **after** 'exit_cb' and I always get something in quickfix window
> like:
> 
> hello.c:1: xxxxxxx       -> 'callback'
> hello.c:2: xxxxxxx       -> 'callback'
> hello.c:3: xxxxxxx       -> 'callback'
> [Finished in 2 seconds]  -> 'exit_cb'
> hello.c:4: xxxxxxx       -> 'callback'
> hello.c:5: xxxxxxx       -> 'callback'
> (pipe close)             -> 'close_cb'
> 
> and sometimes it become this:
> 
> hello.c:1: xxxxxxx       -> 'callback'
> hello.c:2: xxxxxxx       -> 'callback'
> hello.c:3: xxxxxxx       -> 'callback'
> hello.c:4: xxxxxxx       -> 'callback'
> hello.c:5: xxxxxxx       -> 'callback'
> (pipe close)             -> 'close_cb'
> [Finished in 2 seconds]  -> 'exit_cb'
> 
> I just can't figure out which callback is the last one ? and when
> should I dispose my job state ? 'exit_cb' or 'close_cb' ?
> 
> Is this possible to guarantee that 'exit_cb' will always be called at
> last (after 'close_cb' and any other 'callback' / 'out_cb' / 'err_cb')
> ?
> 
> If so, my building system will be much easier.

The exit_cb is invoked as soon as Vim detects that the process is no
longer running.  There is no direct relation with close_cb, because data
may be buffered.  That's what you get with async jobs.

Before the close_cb is invoked, any callbacks for buffered data are
invoked.  Thus you can use close_cb to know that no more data is
coming. I hope this works for you.

Please mention your version number, recent changes may affect what
happens.

-- 
ARTHUR:       Now stand aside worthy adversary.
BLACK KNIGHT: (Glancing at his shoulder) 'Tis but a scratch.
ARTHUR:       A scratch?  Your arm's off.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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