semaphore: allow counter to go negative.
semaphore: allow counter to go negative.

There are situations in which a semaphore is used for accounting a
resource, but the maximum amount allowed is smaller than one individual
request.

We can still use a semaphore in this case, but we must allow it to
"borrow" from future units, or in other words, go negative.

Let's use, as an example, a case in which we are trying to limit the
amount of memory used by all requests in a system to 10MB. Let's say
that one request itself uses 20MB. We can still process it if we allow
the semaphore to store "-10MB" in its counter. When the resource
completes, a signal of 20MB will move it back to its old 10MB. If it
completes piecemeal, at some point the counter will go positive again
and small requests may be allowed in.

In order to use that, we need a non blocking version of wait(), which
will account for the resource unconditionally, even if we have no units
in the counter. Since it doesn't really ever wait(), we'll have to use
a different name for it: consume.

Signed-off-by: Glauber Costa <7ba9037b0dd006f9408bd45b94707becd5cd4e87@scylladb.com>

avikivity/seastar,syuu1228/seastar,scylladb/seastar,avikivity/seastar,avikivity/seastar,dreamsxin/seastar,cloudius-systems/seastar,syuu1228/seastar,syuu1228/seastar,scylladb/seastar,dreamsxin/seastar,dreamsxin/seastar,cloudius-systems/seastar,cloudius-systems/seastar,scylladb/seastar