On Wed, Jan 15, 2014 at 2:23 PM, Ben Fritz <[email protected]> wrote: > So, your background thread is directly calling a function to get user > input/update the screen? I think THAT is a mistake. This should not happen. A > background thread can be used for data processing, but any user input, buffer > changes, screen updates, etc. should ALWAYS be handled in the main thread, > possibly in a deferred function. A background thread should ALWAYS be able to > have the main thread interrupt it. Calling functions in the background which > remove things from Vim's input queue or redraw the screen is begging for > trouble. I thought that was the point of the deferred functions, to allow all > such things to happen in the foreground thread. If you allow calling any > arbitrary Vim function in a background thread, then we would need to make > every arbitrary Vim function thread-safe, and this project becomes huge to > the point of being unmanageable. > > I think the "deferred function executed in the main thread" is a clever idea, > but to use it the background thread can only access data that the foreground > thread will not be accessing, except in the deferred function designed for > it. Redrawing the screen, getting user input, or whatever all need to happen > in the foreground thread ONLY. If you need to change text or redraw the > screen, call a deferred function to do it. >
No. The background thread reads a single character, but only when asked by the main thread. That is required because the main thread will block waiting for a message, which can come from other threads. The only way I know of making a single-threaded program wait for multiple events is through select-like system calls, but then the 'messages' would have to come from other processes -- -- 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/groups/opt_out.
