Excerpts from Tony Mechelynck's message of Sat Jul 18 20:09:19 +0200 2009: > > On 18/07/09 17:21, Marc Weber wrote: > > > > Excerpts from Tony Mechelynck's message of Sat Jul 18 16:01:20 +0200 2009: > >> This said, IIUC Vim is basically a single-threaded application. Threads > >> can (I think) only happen due to interfaces with threaded interpreters. > > Ah thanks, I'll try to add pthread_getthreadid_np to verify this.
I used pthread_self() to get some more debugging information. current updated patch: http://www.mawercer.de/~marc/threadsafe.patch (or get git://mawercer.de/vim branch t/locking) Status: Console: no crash Gtk: my simple counter [1] works fine. However running my heavy test [2] causes some infinite locking somewhere. Athena: Seems to work as fine as console (?) *: I didn't test nor payed attention I'm sure I've missed many race conditions etc.. Implementing this properly would take much more time . So I reached my goal: Being able to run grep or make like commands in background using console vim. Maybe I would have had more sucess adding kind of messaging queue. So that vim.command or vim.eval adds a request to a list which is run from within the main thread and event loop? Then there would have been no threading problems. If you say you're interested in this topic I may implement and try it. Also I'd have more success if someone guides me here. Thank you for paying attention. Marc Weber [1] counter test: py << EOF from subprocess import Popen, PIPE import threading import os import vim print "python start" from time import sleep class MyThread ( threading.Thread ): def run ( self ): counter = 0 while 1: counter += 1 vim.command("echo %d" % counter) sleep(1) thread = MyThread() thread.start() EOF [2] heavy test: fun! Test() py << EOF from subprocess import Popen, PIPE import threading import os import vim print "python start" from time import sleep class MyThread ( threading.Thread ): def __init__(self, start, command): vim.command(start) threading.Thread.__init__(self) self.command=command def run ( self ): sleep(3) for i in range(1,200): vim.command(self.command) vim.command("let g:started=0") for i in range(1,200): thread=MyThread("let g:start=1 | echo \"starting\"", "let g:done=1| echo \"succ\"") thread.start() vim.command("let g:started = g:started+1") print "python thread started" EOF endfun call Test() --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
