diff --git a/build.zig.zon b/build.zig.zon index 221cc2bb7d..3221ade708 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -14,8 +14,8 @@ .hash = "122084badadeb91106dd06b2055119a944c340563536caefd8e22d4064182f7cd6e6", }, .luv = .{ - .url = "git+https://github.com/luvit/luv?ref=1.51.0-0#6cbf6c959a47b6e3ce0679d89ee14d8ed84788b3", - .hash = "N-V-__8AAFglDwBDITf14pNH9v1JzRZneQ_aV_8ytBlzhyNx", + .url = "git+https://github.com/luvit/luv?ref=1.51.0-1#4c9fbc6cf6f3338bb0e0426710cf885ee557b540", + .hash = "N-V-__8AAMlNDwCY07jUoMiq3iORXdZy0uFWKiHsy8MaDBJA", }, .lua_compat53 = .{ .url = "https://github.com/lunarmodules/lua-compat-5.3/archive/v0.13.tar.gz", diff --git a/cmake.deps/deps.txt b/cmake.deps/deps.txt index 9d54193905..e69636d743 100644 --- a/cmake.deps/deps.txt +++ b/cmake.deps/deps.txt @@ -10,8 +10,8 @@ LUA_SHA256 2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333 UNIBILIUM_URL https://github.com/neovim/unibilium/archive/v2.1.2.tar.gz UNIBILIUM_SHA256 370ecb07fbbc20d91d1b350c55f1c806b06bf86797e164081ccc977fc9b3af7a -LUV_URL https://github.com/luvit/luv/archive/1.51.0-0.tar.gz -LUV_SHA256 61f49840c067a8dec288dc841ea5cc20e81852d295068805c4ca1d744c82da7d +LUV_URL https://github.com/luvit/luv/archive/1.51.0-1.tar.gz +LUV_SHA256 d4a11178ae8e16ba5886799ea91905dd9b0b479c75aebd67866d37373e41526f LPEG_URL https://github.com/neovim/deps/raw/d495ee6f79e7962a53ad79670cb92488abe0b9b4/opt/lpeg-1.1.0.tar.gz LPEG_SHA256 4b155d67d2246c1ffa7ad7bc466c1ea899bbc40fef0257cc9c03cecbaed4352a diff --git a/runtime/doc/luvref.txt b/runtime/doc/luvref.txt index 92cbcc8fbc..209939c75e 100644 --- a/runtime/doc/luvref.txt +++ b/runtime/doc/luvref.txt @@ -3915,6 +3915,70 @@ uv.sleep({msec}) *uv.sleep()* Returns: Nothing. +uv.new_sem([{value}]) *uv.new_sem()* + + Parameters: + - `value`: `integer` or `nil` + + Creates a new semaphore with the specified initial value. A + semaphore is safe to share across threads. It represents an + unsigned integer value that can incremented and decremented + atomically but any attempt to make it negative will "wait" + until the value can be decremented by another thread + incrementing it. + + The initial value must be a non-negative integer. + + Returns: `luv_sem_t userdata` or `fail` + + Note: A semaphore must be shared between threads, any + `uv.sem_wait()` on a single thread that blocks will deadlock. + +uv.sem_post({sem}) *uv.sem_post()* + + > method form `sem:post()` + + Parameters: + - `sem`: `luv_sem_t userdata` + + Increments (unlocks) a semaphore, if the semaphore's value + consequently becomes greater than zero then another thread + blocked in a sem_wait call will be woken and proceed to + decrement the semaphore. + + Returns: Nothing. + +uv.sem_wait({sem}) *uv.sem_wait()* + + > method form `sem:wait()` + + Parameters: + - `sem`: `luv_sem_t userdata` + + Decrements (locks) a semaphore, if the semaphore's value is + greater than zero then the value is decremented and the call + returns immediately. If the semaphore's value is zero then the + call blocks until the semaphore's value rises above zero or + the call is interrupted by a signal. + + Returns: Nothing. + +uv.sem_trywait({sem}) *uv.sem_trywait()* + + > method form `sem:trywait()` + + Parameters: + - `sem`: `luv_sem_t userdata` + + The same as `uv.sem_wait()` but returns immediately if the + semaphore is not available. + + If the semaphore's value was decremented then `true` is + returned, otherwise the semaphore has a value of zero and + `false` is returned. + + Returns: `boolean` + ============================================================================== MISCELLANEOUS UTILITIES *luv-miscellaneous-utilities* diff --git a/runtime/lua/uv/_meta.lua b/runtime/lua/uv/_meta.lua index 7283b0236f..a4a9ac2a13 100644 --- a/runtime/lua/uv/_meta.lua +++ b/runtime/lua/uv/_meta.lua @@ -3946,6 +3946,62 @@ function luv_thread_t:getname() end --- @param msec integer function uv.sleep(msec) end +--- Creates a new semaphore with the specified initial value. A semaphore is safe to +--- share across threads. It represents an unsigned integer value that can incremented +--- and decremented atomically but any attempt to make it negative will "wait" until +--- the value can be decremented by another thread incrementing it. +--- +--- The initial value must be a non-negative integer. +--- **Note**: +--- A semaphore must be shared between threads, any `uv.sem_wait()` on a single thread that blocks will deadlock. +--- @param value integer? +--- @return uv.luv_sem_t? sem +--- @return string? err +--- @return uv.error_name? err_name +function uv.new_sem(value) end + +--- Increments (unlocks) a semaphore, if the semaphore's value consequently becomes +--- greater than zero then another thread blocked in a sem_wait call will be woken +--- and proceed to decrement the semaphore. +--- @param sem uv.luv_sem_t +function uv.sem_post(sem) end + +--- @class uv.luv_sem_t : userdata +local luv_sem_t = {} + +--- Increments (unlocks) a semaphore, if the semaphore's value consequently becomes +--- greater than zero then another thread blocked in a sem_wait call will be woken +--- and proceed to decrement the semaphore. +function luv_sem_t:post() end + +--- Decrements (locks) a semaphore, if the semaphore's value is greater than zero +--- then the value is decremented and the call returns immediately. If the semaphore's +--- value is zero then the call blocks until the semaphore's value rises above zero or +--- the call is interrupted by a signal. +--- @param sem uv.luv_sem_t +function uv.sem_wait(sem) end + +--- Decrements (locks) a semaphore, if the semaphore's value is greater than zero +--- then the value is decremented and the call returns immediately. If the semaphore's +--- value is zero then the call blocks until the semaphore's value rises above zero or +--- the call is interrupted by a signal. +function luv_sem_t:wait() end + +--- The same as `uv.sem_wait()` but returns immediately if the semaphore is not available. +--- +--- If the semaphore's value was decremented then `true` is returned, otherwise the semaphore +--- has a value of zero and `false` is returned. +--- @param sem uv.luv_sem_t +--- @return boolean +function uv.sem_trywait(sem) end + +--- The same as `uv.sem_wait()` but returns immediately if the semaphore is not available. +--- +--- If the semaphore's value was decremented then `true` is returned, otherwise the semaphore +--- has a value of zero and `false` is returned. +--- @return boolean +function luv_sem_t:trywait() end + --- # Miscellaneous utilities @@ -4474,4 +4530,3 @@ function uv.wtf8_to_utf16(wtf8) end --- @class uv.uv_work_t : uv.uv_req_t --- @class uv.uv_write_t : uv.uv_req_t -