async-rails 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee25678b86dee1c30ef7c20508e540a67521fa93
4
- data.tar.gz: bf0979d5a97b7d801b8acde08c1e270cf03f3aad
3
+ metadata.gz: 4dc696b7450ba8f34c9f3066b300a77660644356
4
+ data.tar.gz: 07ece37305768c4e89d0891a0fafa0aad841b67d
5
5
  SHA512:
6
- metadata.gz: 619a704271bfda8e8a5d57fc9814222f7ebb1b5457c0bf553cfd60c58a025ed4274741b46c3562e29b2e1ff29d6459529e9d71b063ddcdb72fe7d1543967fa4a
7
- data.tar.gz: f01203e1c6fad4832de47cbe0f36c3ce143eb7951fb66b72564d0885def9982c7d1364f6099491957d55c426f6623548bedb6d032325130982a6dc70319e856a
6
+ metadata.gz: 9f0163a70f13e3bc1c9e70e9c0b599f0755c88e84250e92822fd4f39be66019154a5eb73cbc32a5da82e8e3b37e874f5aea6f2e67c55c9b41a99459e00e8eab1
7
+ data.tar.gz: 011567913c47a220c909da89dfe8595855be4abd721db6dee5129a3e958477a10f03baafe9344e2b26a8537e04e3c401042a7264240281ef56d32848118b0755
@@ -1,5 +1,5 @@
1
1
  module Async
2
2
  module Rails
3
- VERSION = "0.4.1"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -725,6 +725,7 @@
725
725
  saturated: null,
726
726
  empty: null,
727
727
  drain: null,
728
+ paused: false,
728
729
  push: function (data, callback) {
729
730
  _insert(q, data, false, callback);
730
731
  },
@@ -732,7 +733,7 @@
732
733
  _insert(q, data, true, callback);
733
734
  },
734
735
  process: function () {
735
- if (workers < q.concurrency && q.tasks.length) {
736
+ if (!q.paused && workers < q.concurrency && q.tasks.length) {
736
737
  var task = q.tasks.shift();
737
738
  if (q.empty && q.tasks.length === 0) {
738
739
  q.empty();
@@ -760,6 +761,16 @@
760
761
  },
761
762
  idle: function() {
762
763
  return q.tasks.length + workers === 0;
764
+ },
765
+ pause: function () {
766
+ if (q.paused === true) { return; }
767
+ q.paused = true;
768
+ q.process();
769
+ },
770
+ resume: function () {
771
+ if (q.paused === false) { return; }
772
+ q.paused = false;
773
+ q.process();
763
774
  }
764
775
  };
765
776
  return q;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Chen