[vim/vim] Multi-threading problem: any workaround? (Discussion #19371)

5 views
Skip to first unread message

ubaldot

unread,
Feb 9, 2026, 2:50:51 AM (yesterday) Feb 9
to vim/vim, Subscribed

I want to get a custom list for a user-command whose information comes from a job. When I query the job the response is captured by the out_cb callback.

In my mind I should implement a semaphore to have a sound solution:

GetInfoForCompletionList() -> QueryJob() (turn semaphore on) -> wait for out on out_cb -> message received (turn semaphore off) -> GetInfoForCompletionList() is now unlocked and can display the result.

but I am not even sure if it works because Vim does not support multi-threading.

Any workaround to cope with this problem?


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/repo-discussions/19371@github.com>

Paul Ollis

unread,
Feb 9, 2026, 4:12:00 PM (19 hours ago) Feb 9
to vim/vim, Subscribed

Assuming I understand your scenario correctly.

Since Vim only ever uses a single thread you should be able to use
a simple flag.

GetInfoForCompletionList() can loop until the flag is set. Perhaps
something like:

    let g:reply = []
    let g:flag = 0
    call QueryJob()
    while g:flag == 0
        :sleep 1ms
    endwhile

    " Now g:replay has data read by the `out_cb`.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/repo-discussions/19371/comments/15748611@github.com>

Reply all
Reply to author
Forward
0 new messages