peplum 0.2.1 → 0.2.2

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: 684acaeb0eb2b2cccf49d9959482b56da2a73cf6da28d5c6f34833c015a889be
4
- data.tar.gz: 5fb7a928493b17e94abb647f5779dd79671df3443d6bc1cc5063e1ee54f196e1
3
+ metadata.gz: 3cf68ae5865f247eefd32f97a3171b4306fdf421a8e73df30429d4ee91c32232
4
+ data.tar.gz: d26d484ab649e0258ab2855ac81e14db8dbbb9a06509cf00a5d4b957b188ce6e
5
5
  SHA512:
6
- metadata.gz: 12ae57302cc03176c3e760f0d3ffece96216dfdf70bb006c758a63c661f10a57aa71abca25a8560028cfacff3f87c95611eed882d50a63e6867fe8bb8471531d
7
- data.tar.gz: 2066cd3a32f3b4e2ba294c553b406ad32ea54c7bba34a0f38f9cc7c66addf5358e57127aec01eb2c271ff4e51f0f1b2a4259410286a09a77ec414dcd3726a6d8
6
+ metadata.gz: 18d05dda4ecd556ba03556dae0754a5c4e085cb90c9f77536abc5156147529b941a9377d3bdf9cfe2b124f0dae4a6cb403d1315190a0a9b0817ab16130c7b383
7
+ data.tar.gz: 58438b5a98f06d5353cbb4ffa5b9f65b15c7d51401a40498af6f82c9c09a4483e04b6bc78ddeda8427bab930c7402e720015c757d490494876877767c019d5a6
@@ -5,49 +5,38 @@ module Services
5
5
  class SharedHash
6
6
 
7
7
  def initialize
8
- @hash = {}
9
- @sync_counter = 0
8
+ @hash = {}
10
9
  end
11
10
 
12
11
  def get( k )
13
12
  @hash[k]
14
13
  end
15
14
 
16
- def set( k, v, broadcast = true, &block )
17
- if @hash[k] == v
18
- block.call if block_given?
19
- return
20
- end
15
+ def set( k, v, broadcast = true )
16
+ return if @hash[k] == v
21
17
 
22
18
  @hash[k] = v
23
19
 
24
20
  if broadcast
25
21
  each_peer do |peer|
26
- @sync_counter += 1
27
- peer.shared_hash.set( k, v, false ) { @sync_counter -= 1 }
22
+ peer.shared_hash.set( k, v, false )
28
23
  end
29
24
  end
30
25
 
31
- block.call if block_given?
32
26
  nil
33
27
  end
34
28
 
35
29
  def delete( k, broadcast = true )
36
- if !@hash.include? k
37
- block.call if block_given?
38
- return
39
- end
30
+ return if !@hash.include? k
40
31
 
41
32
  @hash.delete( k )
42
33
 
43
34
  if broadcast
44
35
  each_peer do |_, peer|
45
- @sync_counter += 1
46
- peer.shared_hash.delete( k, false ) { @sync_counter -= 1 }
36
+ peer.shared_hash.delete( k, false )
47
37
  end
48
38
  end
49
39
 
50
- block.call if block_given?
51
40
  nil
52
41
  end
53
42
 
@@ -55,10 +44,6 @@ class SharedHash
55
44
  @hash.dup
56
45
  end
57
46
 
58
- def sync
59
- sleep 0.1 while @sync_counter != 0
60
- end
61
-
62
47
  private
63
48
 
64
49
  def each_peer( &block )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Peplum
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
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.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tasos Laskos