File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
client/strategies/integrated Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ return function(spec)
2929 assert (not open_err , open_err )
3030
3131 output_accum :subscribe (function (data )
32- vim .loop .fs_write (output_fd , data , nil , function (write_err )
32+ vim .uv .fs_write (output_fd , data , nil , function (write_err )
3333 assert (not write_err , write_err )
3434 end )
3535 end )
@@ -45,7 +45,7 @@ return function(spec)
4545 output_finish_future .set ()
4646 return
4747 end
48- output_accum :push (table.concat (data , " \n " ))
48+ nio . run ( function () output_accum :push (table.concat (data , " \n " )) end )
4949 end ,
5050 on_exit = function (_ , code )
5151 result_code = code
Original file line number Diff line number Diff line change 1+ local nio = require (" nio" )
12local logger = require (" neotest.logging" )
23local neotest = {}
34
@@ -7,6 +8,7 @@ local neotest = {}
78--- @field consumers fun ( data : T ) []
89--- @field data ? T
910--- @field accum fun ( prev : T , new : any ): T A function to combine previous data and new data
11+ --- @field semaphore nio.control.Semaphore
1012neotest .FanoutAccum = {}
1113
1214--- @generic T
@@ -19,6 +21,7 @@ function neotest.FanoutAccum:new(accum, init)
1921 data = init ,
2022 accum = accum ,
2123 consumers = {},
24+ semaphore = nio .control .semaphore (1 )
2225 }, self )
2326end
2427
@@ -40,12 +43,15 @@ function neotest.FanoutAccum:subscribe(cb)
4043 end
4144end
4245
46+ --- @async
4347--- @param data T
4448function neotest .FanoutAccum :push (data )
45- self .data = self .accum (self .data , data )
46- for _ , cb in ipairs (self .consumers ) do
47- cb (data )
48- end
49+ self .semaphore .with (function ()
50+ self .data = self .accum (self .data , data )
51+ for _ , cb in ipairs (self .consumers ) do
52+ cb (data )
53+ end
54+ end )
4955end
5056
5157--- @private
You can’t perform that action at this time.
0 commit comments