On Wednesday, January 15, 2014 10:08:53 AM UTC-6, Thiago Arruda wrote:
> 
> 
> Ashley, its possible that a 'DeferredCall' message arrives while
> 
> the background thread is in the middle of running 'vgetc'. A DeferredCall will
> 
> invoke a vimscript function and then will update the screen which might cause
> 
> the race condition. Thanks for pointing that bug, I could not see it at first.
> 

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.

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

Raspunde prin e-mail lui