concurrent-shm 0.1.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.
@@ -0,0 +1,26 @@
1
+ # Shared Memory Concurrency
2
+ module ConcurrentSHM
3
+ # Gem data
4
+ module Gem
5
+ # Gem name
6
+ NAME = 'concurrent-shm'
7
+
8
+ # Gem version
9
+ VERSION = '0.1.0'
10
+
11
+ # Gem summary
12
+ SUMMARY = 'Shared Memory Concurrency'
13
+
14
+ # Gem description
15
+ DESCRIPTION = 'Multi-process concurrent structures utilizing shared memory - NOT SUPPORTED FOR WINDOWS'
16
+
17
+ # Gem authors
18
+ AUTHORS = ['Ethan Reesor']
19
+
20
+ # Gem website
21
+ WEBSITE = 'https://gitlab.com/firelizzard/concurrent-shm'
22
+
23
+ # Gem license
24
+ LICENSE = 'Apache-2.0'
25
+ end
26
+ end
@@ -0,0 +1,53 @@
1
+ module ConcurrentSHM
2
+ # Value pointers.
3
+ module Value
4
+ # Base class for integer pointers.
5
+ # @abstract Subclasses must override {#read} and {#write}.
6
+ class IntPtr
7
+ # Read from the pointer.
8
+ # @return [Integer]
9
+ def read
10
+ raise NotImplementedError
11
+ end
12
+
13
+ # Write to the pointer.
14
+ # @param value [Integer]
15
+ # @return [nil]
16
+ def write(value)
17
+ raise NotImplementedError
18
+ end
19
+
20
+ # Read from the pointer. If `bit` is non-nil, read the specified bit.
21
+ # @param bit [Integer] the bit position to read
22
+ # @return [Integer] the value of the pointer
23
+ # @raise [ArgumentError] if the bit is not nil or an integer
24
+ def [](bit=nil)
25
+ return read if bit.nil?
26
+ return (read >> bit) & 0x1 if bit.is_a?(Integer)
27
+
28
+ raise ArgumentError, "Invalid index: #{bit.inspect}"
29
+ end
30
+
31
+ # Writes to the pointer. If `bit` is non-nil, write the specified bit.
32
+ # @param bit [Integer] the bit position to read
33
+ # @param v [Integer] the value to write
34
+ # @raise [IntDomainError] if the write under or overflows
35
+ # @raise [ArgumentError] if the value is not an integer or boolean, or if the bit is not nil or an integer
36
+ def []=(bit=nil, v)
37
+ case bit
38
+ when nil
39
+ write(v)
40
+ when Integer
41
+ if v
42
+ write(read | (1 << bit))
43
+ else
44
+ write(read & ~(1 << bit))
45
+ end
46
+
47
+ else
48
+ raise ArgumentError, "Invalid index: #{bit.inspect}"
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: concurrent-shm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ethan Reesor
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-10-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Multi-process concurrent structures utilizing shared memory - NOT SUPPORTED
14
+ FOR WINDOWS
15
+ email:
16
+ executables: []
17
+ extensions:
18
+ - ext/concurrent-shm/extconf.rb
19
+ extra_rdoc_files: []
20
+ files:
21
+ - AUTHORS
22
+ - CHANGELOG.md
23
+ - LICENSE
24
+ - README.md
25
+ - ext/concurrent-shm/extconf.rb
26
+ - ext/concurrent-shm/main.c
27
+ - ext/concurrent-shm/main.h
28
+ - ext/concurrent-shm/posix.c
29
+ - ext/concurrent-shm/types.c
30
+ - ext/concurrent-shm/varargs.h
31
+ - lib/concurrent-shm.rb
32
+ - lib/concurrent-shm/channel.rb
33
+ - lib/concurrent-shm/gem.rb
34
+ - lib/concurrent-shm/int_ptr.rb
35
+ homepage: https://gitlab.com/firelizzard/concurrent-shm
36
+ licenses:
37
+ - Apache-2.0
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubygems_version: 3.0.3
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Shared Memory Concurrency
58
+ test_files: []