SuspendableThrottlerCount

Simple suspendable throttler which just counts the number of pending items, and throttles the suspendables based on that count. No data other than the pending count is stored.

Constructors

this
this(size_t suspend_point, size_t resume_point)

Constructor.

Members

Aliases

add
alias add = inc
Undocumented in source.
remove
alias remove = dec
Undocumented in source.

Functions

add
void add(size_t n)

Increases the count of pending items and throttles the suspendables.

dec
void dec()

Decreases the count of pending items and throttles the suspendables.

inc
void inc()

Increases the count of pending items and throttles the suspendables.

length
size_t length()
opOpAssign
void opOpAssign(size_t n)

Increases the count of pending items and throttles the suspendables.

opOpAssign
void opOpAssign(size_t n)

Decreases the count of pending items and throttles the suspendables.

opUnary
void opUnary()

Increases the count of pending items and throttles the suspendables.

opUnary
void opUnary()

Decreases the count of pending items and throttles the suspendables.

remove
void remove(size_t n)

Decreases the count of pending items and throttles the suspendables.

Inherited Members

From ISuspendableThrottlerCount

suspend_point
const(size_t) suspend_point;

When the number of pending items reaches this value or greater, the suspendables will be suspended.

resume_point
const(size_t) resume_point;

When the number of pending items reaches this value or less, the suspendables will be resumed.

length
size_t length()
suspend
bool suspend()

Decides whether the suspendables should be suspended. Called by throttle() when not suspended.

resume
bool resume()

Decides whether the suspendables should be resumed. Called by throttle() when suspended.

Examples

SuspendableThrottlerCount unittest.

static class SuspendableThrottlerCount_Test : ISuspendableThrottlerCount_Test
{
    private SuspendableThrottlerCount count;

    this ( )
    {
        this.count = new SuspendableThrottlerCount(this.suspend, this.resume);
        super(this.count);
    }

    override void inc ( )
    {
        this.count++;
    }

    override void dec ( )
    {
        this.count--;
    }
}

scope test = new SuspendableThrottlerCount_Test;

Meta