From 055b35cd561a67d02ae52c9c0932bfc04b83175f Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Wed, 21 Dec 2016 12:31:04 -0500 Subject: [PATCH] Small improvement to lock --- autoload/langserver/lock.vim | 16 ++++++++++++++-- tests/test_lock.vader | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/autoload/langserver/lock.vim b/autoload/langserver/lock.vim index 83c6cdb..81a9826 100644 --- a/autoload/langserver/lock.vim +++ b/autoload/langserver/lock.vim @@ -7,10 +7,22 @@ function! s:dict_unlock() dict let self.locked = v:false endfunction +function! s:set_id(job_id) dict + let self.id = a:job_id +endfunction + +function! s:get_id() dict + return self.id +endfunction + function! langserver#lock#semaphore() abort - let l:ret = {} - let l:ret.locked = v:false + let l:ret = { + \ 'id': -1, + \ 'locked': v:false, + \ } let l:ret.lock = function('s:dict_lock') let l:ret.unlock = function('s:dict_unlock') + let l:ret.set_id = function('s:set_id') + let l:ret.get_id = function('s:get_id') return l:ret endfunction diff --git a/tests/test_lock.vader b/tests/test_lock.vader index b6cdad1..f00580c 100644 --- a/tests/test_lock.vader +++ b/tests/test_lock.vader @@ -8,3 +8,8 @@ Execute (Test Lock): call my_lock.unlock() AssertEqual v:false, my_lock.locked + + AssertEqual -1, my_lock.get_id() + + call my_lock.set_id(1) + AssertEqual 1, my_lock.get_id()