nickva commented on code in PR #5414:
URL: https://github.com/apache/couchdb/pull/5414#discussion_r1929937944


##########
src/couch/src/couch_work_queue.erl:
##########
@@ -95,23 +96,20 @@ handle_call({queue, Item, Size}, From, #q{work_waiters = 
[]} = Q0) ->
         false ->
             {reply, ok, Q, hibernate}
     end;
-handle_call({queue, Item, _}, _From, #q{work_waiters = [{W, _Max} | Rest]} = 
Q) ->
+handle_call({queue, Item, _}, _From, #q{worker = {W, _Max}} = Q) ->
     gen_server:reply(W, {ok, [Item]}),
-    {reply, ok, Q#q{work_waiters = Rest}, hibernate};
-handle_call({dequeue, Max}, From, Q) ->
-    #q{work_waiters = Workers, multi_workers = Multi, items = Count} = Q,
-    case {Workers, Multi} of
-        {[_ | _], false} ->
-            exit("Only one caller allowed to wait for this work at a time");
-        {[_ | _], true} ->
-            {noreply, Q#q{work_waiters = Workers ++ [{From, Max}]}};
-        _ ->
-            case Count of
-                0 ->
-                    {noreply, Q#q{work_waiters = Workers ++ [{From, Max}]}};
-                C when C > 0 ->
-                    deliver_queue_items(Max, Q)
-            end
+    {reply, ok, Q#q{worker = undefined}, hibernate};
+handle_call({dequeue, _Max}, _From, #q{worker = {_, _}}) ->
+    % Something went wrong - the same or a different worker is
+    % trying to dequeue an item. We only only allow one worker to wait

Review Comment:
   Thank you! I tried the "commit suggestion" GH feature for the first time to 
see how that works.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to