~michihenning/thumbnailer/remove-arm-hardware-hack

« back to all changes in this revision

Viewing changes to include/ratelimiter.h

  • Committer: Tarmac
  • Author(s): Michi Henning
  • Date: 2015-10-14 05:11:41 UTC
  • mfrom: (278.4.20 qt-rate-limiter)
  • Revision ID: tarmac-20151014051141-kyem0nctbyjgrczs
Moved rate limiter from QML to Qt side.
Fixed bug in libthumbnailer-qt that caused the state of completed request to not be released.
Changed stress test to test the rate limiting via Qt.

Approved by PS Jenkins bot, James Henstridge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
// RateLimiter is a simple class to control the level of concurrency
33
33
// of asynchronous jobs.  It performs no locking because it is only
34
34
// intended to be run from the event loop thread.
35
 
class RateLimiter {
 
35
 
 
36
class RateLimiter
 
37
{
36
38
public:
37
39
    RateLimiter(int concurrency);
38
40
    ~RateLimiter();
44
46
    // reached, the job will be run immediately.  Otherwise it will be
45
47
    // added to the queue. Return value is a function that, when
46
48
    // called, cancels the job in the queue (if it's still in the queue).
47
 
    std::function<void()> schedule(std::function<void()> job);
 
49
    std::function<void() noexcept> schedule(std::function<void()> job);
48
50
 
49
51
    // Notify that a job has completed.  If there are queued jobs,
50
52
    // start the one at the head of the queue.