peplum 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba9afc619d143df37446d3a6106a81df6fa2e7123faf3266d764b07221526361
4
- data.tar.gz: c1317747cf60bb0ad277afcd18e37a9f75d669a1fffa3152e6d433bc415b1178
3
+ metadata.gz: 684acaeb0eb2b2cccf49d9959482b56da2a73cf6da28d5c6f34833c015a889be
4
+ data.tar.gz: 5fb7a928493b17e94abb647f5779dd79671df3443d6bc1cc5063e1ee54f196e1
5
5
  SHA512:
6
- metadata.gz: 1451674a3ba4585df1efd8acdb2ad2860f83b4b12f446b51de6ecda1caa858ba5c9eaf5c5b4046181eca54cce5690969a5d6072818d13f3dc25c51ab198590c8
7
- data.tar.gz: 9a3c612baae480207d083a3276c9c9aba9aeb6b13781435634b8336fe12ac3c8b21a210044d00dab954099ed7d5c82b023a9d383125594303c487cce37c6ed64
6
+ metadata.gz: 12ae57302cc03176c3e760f0d3ffece96216dfdf70bb006c758a63c661f10a57aa71abca25a8560028cfacff3f87c95611eed882d50a63e6867fe8bb8471531d
7
+ data.tar.gz: 2066cd3a32f3b4e2ba294c553b406ad32ea54c7bba34a0f38f9cc7c66addf5358e57127aec01eb2c271ff4e51f0f1b2a4259410286a09a77ec414dcd3726a6d8
@@ -5,7 +5,8 @@ module Services
5
5
  class SharedHash
6
6
 
7
7
  def initialize
8
- @hash = {}
8
+ @hash = {}
9
+ @sync_counter = 0
9
10
  end
10
11
 
11
12
  def get( k )
@@ -22,7 +23,8 @@ class SharedHash
22
23
 
23
24
  if broadcast
24
25
  each_peer do |peer|
25
- peer.shared_hash.set( k, v, false ) {}
26
+ @sync_counter += 1
27
+ peer.shared_hash.set( k, v, false ) { @sync_counter -= 1 }
26
28
  end
27
29
  end
28
30
 
@@ -40,7 +42,8 @@ class SharedHash
40
42
 
41
43
  if broadcast
42
44
  each_peer do |_, peer|
43
- peer.shared_hash.delete( k, false ) {}
45
+ @sync_counter += 1
46
+ peer.shared_hash.delete( k, false ) { @sync_counter -= 1 }
44
47
  end
45
48
  end
46
49
 
@@ -52,6 +55,10 @@ class SharedHash
52
55
  @hash.dup
53
56
  end
54
57
 
58
+ def sync
59
+ sleep 0.1 while @sync_counter != 0
60
+ end
61
+
55
62
  private
56
63
 
57
64
  def each_peer( &block )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Peplum
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peplum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tasos Laskos