Simple use of jobs application failing

bengt cean.ebengt@REDACTED
Sat Nov 13 18:12:45 CET 2021


Greetings,

I would like to allow at most 3 processes to call a gen_server at the same time. I could check the message queue length, but why not use jobs (https://github.com/uwiger/jobs) ?

Jobs is already in use by something I depend on, so it should be working. I test from the (iex) shell. As can be seen below I am making a mistake somewhere. Probably config, so how should I configure to only get 3 of the 5 jobs:ask/1 to be approved and queued? Or I have misunderstood the use, and an explanation of how to achieve the 3 caller limitation would be appreciated.

 :jobs.add_queue(:kalle,  [{:max_size, 3}])
  for _ <- [1,2,3,4,5], do: :jobs.ask(:kalle)
  IO.inspect :jobs.queue_info(:kalle)

   name: :kalle,
   max_size: 3,
   approved: 5,
   queued: 5,
   latest_dispatch: 378734152926266,
   mod: :jobs_queue,
   type: :fifo,
   group: :undefined,
   regulators: [],
   max_time: :undefined,
   check_interval: :infinity,
   oldest_job: :undefined,
   timer: :undefined,
   link_ref: :undefined,
   check_counter: 0,
   empty: false,
   depleted: false,
   waiters: [],
   stateful: :undefined,
   st: {:st, #Reference<0.2285429207.3584425985.10312>},
   producers: []

Best Wishes,
bengt


More information about the erlang-questions mailing list