3 ms·
In what circumstances would a ‘try_push’ fail on an unbounded queue? On a bounded queue it would fail when the queue is full. The size of the queue can be read
by secondcoming 4y ago
In what circumstances would a ‘try_push’ fail on an unbounded queue?
On a bounded queue it would fail when the queue is full.
The size of the queue can be read from a config file, and is tuned to the capability of the machine.
- amelius 4y ago> In what circumstances would a ‘try_push’ fail on an unbounded queue? When you have an out-of-memory situation. The thing you are trying to express is that you want a queue that stops working only when it physically can't work. Putting arbitrary large numbers in config files is not the way to express it.
- secondcoming 4y agoSo then your program gets killed. Using a bounded queue let's you handle these situations gracefully and then you can tie these errors to alerts, which are then tied to a scaling policy.
- anonymoushn 4y agoThis doesn't seem correct. What if, for example, the long-running tasks would like to allocate memory, and they cannot because the user has clicked the button a few billion times? In that case, it seems like perhaps we should have accepted fewer jobs, so that we would be able to perform the ones we accepted.
- detinho 4y agoIf the only thing you need to allocate memory to is your queue, then maybe. Otherwise you'd incur in problems like the sibling comment. That's the very same reason you limit connection pools on applications that connect to a database: to prevent some instance to use all the database server connections and leave nothing to other instances.