peplum 0.2.3 → 0.2.5

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: 39020843c5d8edc0d848f1b08bc88fdc73aed389241a757f3b8f55cd1b5a151e
4
- data.tar.gz: c3a31f27cdd3e95f840cfd0466d6facdf596f8dc306a1063091f5862b19f2ae6
3
+ metadata.gz: aec29bf9b09d3b32cb143536ea66a1550b41008e7856108949ef2a45f74c3761
4
+ data.tar.gz: 656a2e85c329a0005da906ba9f649553277c40feb772930ca66c99b5115be906
5
5
  SHA512:
6
- metadata.gz: 95a6bdcd3f8ce0b86dba303250304e79c3455bbd7f63dc05e226ff5605c7769ce396b7b70f4a0a53144cc0cc0767a70653a0123deac6d756b9b6ab8823489ceb
7
- data.tar.gz: '0806c44ba530ff2cd8e5ec6cc0e53acdd4519a00c5c5b0e5d6514be173f522c2e01fa137ae97fe411ad3d9698d0db2901f3775b98f96e8fb7c9843d31f5ac2f6'
6
+ metadata.gz: 3894e8846b387ab36ba705b9137ab7ea4a122057d62378224bc43f29caaf1600ce27d41ffb3472e81b0524b5d03330f935a3d79a3ae0f7197d4ae8500c218e91
7
+ data.tar.gz: 8c420ac4afbb2788b0434971e6865e33b03d086cc2275bc504fe65f0f06ced8ea729abf26494bc360875c2a3be1ea13a06da5940062a907bc48d0148172c82db
@@ -4,7 +4,11 @@ module Services
4
4
 
5
5
  class SharedHash
6
6
 
7
- def initialize
7
+ CONCURRENCY = 20
8
+
9
+ def initialize(*)
10
+ super
11
+
8
12
  @hash = {}
9
13
 
10
14
  @on_set_cb = {}
@@ -15,33 +19,41 @@ class SharedHash
15
19
  @hash[k]
16
20
  end
17
21
 
18
- def set( k, v, broadcast = true )
19
- return if @hash[k] == v
22
+ def set( k, v, broadcast = true, &block )
23
+ if @hash[k] == v
24
+ block.call if block_given?
25
+ return
26
+ end
20
27
 
21
28
  @hash[k] = v
22
29
  call_on_set( k, v )
23
30
 
24
31
  if broadcast
25
- each_peer do |peer|
26
- peer.shared_hash.set( k, v, false )
32
+ each_peer do |peer, iterator|
33
+ peer.send( name ).set( k, v, false ) { iterator.next }
27
34
  end
28
35
  end
29
36
 
37
+ block.call if block_given?
30
38
  nil
31
39
  end
32
40
 
33
- def delete( k, broadcast = true )
34
- return if !@hash.include? k
41
+ def delete( k, broadcast = true, &block )
42
+ if !@hash.include? k
43
+ block.call if block_given?
44
+ return
45
+ end
35
46
 
36
47
  @hash.delete( k )
37
48
  call_on_delete( k )
38
49
 
39
50
  if broadcast
40
- each_peer do |_, peer|
41
- peer.shared_hash.delete( k, false )
51
+ each_peer do |peer, iterator|
52
+ peer.send( name ).delete( k, false ) { iterator.next }
42
53
  end
43
54
  end
44
55
 
56
+ block.call if block_given?
45
57
  nil
46
58
  end
47
59
 
@@ -80,7 +92,10 @@ class SharedHash
80
92
  end
81
93
 
82
94
  def each_peer( &block )
83
- Cuboid::Application.application.peers.each( &block )
95
+ each = proc do |client, iterator|
96
+ block.call client, iterator
97
+ end
98
+ Raktr.global.create_iterator( Cuboid::Application.application.peers.to_a, CONCURRENCY ).each( each )
84
99
  end
85
100
 
86
101
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Peplum
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peplum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tasos Laskos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-23 00:00:00.000000000 Z
11
+ date: 2023-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cuboid