Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

Commit

Permalink
Small improvement to lock
Browse files Browse the repository at this point in the history
  • Loading branch information
TJ DeVries committed Dec 21, 2016
1 parent c37e5b0 commit 055b35c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
16 changes: 14 additions & 2 deletions autoload/langserver/lock.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions tests/test_lock.vader
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 055b35c

Please sign in to comment.