Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: mix format

+19 -14
+6 -3
apps/nix/lib/nix/eval/queue.ex
··· 48 48 :ordered_set, 49 49 :public, 50 50 {:read_concurrency, true}, 51 - {:write_concurrency, false} # Single writer (GenServer) is fine 51 + # Single writer (GenServer) is fine 52 + {:write_concurrency, false} 52 53 ] 53 54 54 55 table_name = Keyword.get(opts, :name, __MODULE__) ··· 83 84 84 85 # Atomically reserve a range of sequence numbers 85 86 start_seq = :atomics.add_get(counter, 1, count) 86 - start_seq = start_seq - count + 1 # Adjust to get first number in range 87 + # Adjust to get first number in range 88 + start_seq = start_seq - count + 1 87 89 88 90 # Build list of {key, value} tuples 89 91 records = ··· 180 182 case :ets.take(table, key) do 181 183 [{^key, item}] -> 182 184 # Successfully took item, get next key and continue 183 - next_key = :ets.first(table) # After take, first is now the next item 185 + # After take, first is now the next item 186 + next_key = :ets.first(table) 184 187 dequeue_loop(table, count - 1, next_key, [item | acc]) 185 188 186 189 [] ->
+13 -11
apps/nix/test/nix/eval/queue_test.exs
··· 232 232 Queue.enqueue(table, counter, Enum.to_list(1..100)) 233 233 234 234 # Spawn multiple processes to read size 235 - tasks = for _ <- 1..10 do 236 - Task.async(fn -> 237 - Queue.size(table) 238 - end) 239 - end 235 + tasks = 236 + for _ <- 1..10 do 237 + Task.async(fn -> 238 + Queue.size(table) 239 + end) 240 + end 240 241 241 242 results = Task.await_many(tasks) 242 243 assert Enum.all?(results, &(&1 == 100)) ··· 249 250 # This should complete quickly due to read_concurrency 250 251 start = System.monotonic_time(:millisecond) 251 252 252 - tasks = for _ <- 1..100 do 253 - Task.async(fn -> 254 - Queue.size(table) 255 - Queue.empty?(table) 256 - end) 257 - end 253 + tasks = 254 + for _ <- 1..100 do 255 + Task.async(fn -> 256 + Queue.size(table) 257 + Queue.empty?(table) 258 + end) 259 + end 258 260 259 261 Task.await_many(tasks) 260 262 elapsed = System.monotonic_time(:millisecond) - start