win32-ipc 0.6.6 → 0.7.0

This diff has not been reviewed by any users.
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
  SHA1:
3
- metadata.gz: 944acf1e2f12b1cc3846b14d327ce6661876b820
4
- data.tar.gz: 8b75202d9ded7365795ad9cd06aac0cad9c0b8c1
3
+ metadata.gz: 4854bf6c5523a5a3bcb3c35785e0448d36803329
4
+ data.tar.gz: 1e6631654eb37738ea553f54c5f3146d91604bfa
5
5
  SHA512:
6
- metadata.gz: e649133be67ba41f5fd9227d66362eb7a95588c9fb26cd3b426cf70065ed759f09c9fd7b7ab542d37671e203a7f1d47da8f4d08e50692509186d27aa78d5d787
7
- data.tar.gz: 9b3502e7f1418861f83c0558b7d72073082467a38fa675a3584c0bc635a650bfdade68abe5b86089cf09b112f3c8c80e987bfad8d8e39d97742d93e513d30606
6
+ metadata.gz: ccd55f35361002d9a659c50efe71b1b4c3727071cfa7ea0b2d8c6402add2d6f2de820aa5eb0ed9cea3ab0fed0cf4b198f6a36df4f598195f1d51bf5f26a9e308
7
+ data.tar.gz: 15a5278aea868b69aaab99924d60a6c2abbd45b1d05c97de294cb67fddc6d2474364f4c94b264c71f01c286373485702a77c469f5b8bcce1e9e3f910aaa9f8ed
Binary file
data.tar.gz.sig CHANGED
@@ -1,4 +1,2 @@
1
- �a�M�'�ۗ�����Ck�ڀn`�9}uq�����&���
2
- tM�~8�+��k�
3
- ���{����҉Uۘuks����R'�
4
- �+�iӆR�D�[�)��B�k���=D�K��ٟ��V�C�ɓ���m�ʐ�N��g{���!&U�4X>���*T%��C����2�i�몆����(�űݮC<����C���L�Y�b_�IO�W���{ ή5�$�$Pw#U��Fk�z]�M�����?֯�x�����
1
+ J�9;%��H��+a�)�j01K��HZs����M����e��f[da5h"j�xK�y�������N{/�zٯ���1���.o��Ebe�G` ���Ѷ��^&���Ȟ]1кe�<��;X(=Y� =&ݬ�Y�V�*�'1�5]{0CDX��O�ݛmt'�%gmC¥��Ff��r��F2�
2
+ ��1tH�l� ڟR�S�3%~���
data/CHANGES CHANGED
@@ -1,93 +1,96 @@
1
- == 0.6.6 - 13-Sep-2015
2
- * The gem is now signed.
3
- * Added the win32-ipc.rb file for convenience.
4
-
5
- == 0.6.5 - 7-Jul-2015
6
- * Fixed the wait_for_multiple method for x64 platforms. Thanks go to Rafal
7
- Bigaj for the spot and patch.
8
-
9
- == 0.6.4 - 1-Jul-2015
10
- * Fixed boolean argument type parameter. Thanks go to Rafal Bigaj for the patch.
11
- * Updates to gemspec and Rakefile.
12
-
13
- == 0.6.3 - 10-Jan-2015
14
- * Declare the FFI prototype for WaitForSingleObject as blocking.
15
-
16
- == 0.6.2 - 10-Jan-2015
17
- * Declare the FFI prototype for WaitForMultipleObjects as blocking.
18
-
19
- == 0.6.1 - 9-Apr-2013
20
- * Updated the HANDLE function prototypes in the underlying FFI code. This
21
- affects 64 bit versions of Ruby.
22
-
23
- == 0.6.0 - 8-Jul-2012
24
- * Now uses FFI instead of win32-api.
25
- * The #signaled? method now has a meaningful default implementation.
26
- * If an internal C function fails it raises a SystemCallError (Errno) instead
27
- of an Ipc::Error.
28
- * The Ipc::Error class, although defined for those who wish to still use it
29
- in inherited classes, is no longer used internally.
30
-
31
- == 0.5.3 - 19-Apr-2010
32
- * Added a few gem related tasks to the Rakefile, and removed an old install
33
- task.
34
- * Removed the inline gem building code from the gemspec. That's now handled
35
- by a Rake task.
36
- * Some cosmetic changes to the source code.
37
-
38
- == 0.5.2 - 6-Aug-2009
39
- * License changed to Artistic 2.0.
40
- * Some gemspec updates, including an updated description and adding a
41
- license attribute.
42
- * Renamed the test file to test_win32_ipc.rb.
43
-
44
- == 0.5.1 - 1-Jan-2008
45
- * Fixed bugs in the private wait_for_multiple method. Thanks go to an
46
- anonymous user for the spot and the patch.
47
- * Removed the install.rb file. Installation was merged into the Rakefile.
48
- * Updated the MANIFEST.
49
-
50
- == 0.5.0 - 30-Apr-2007
51
- * Now pure Ruby.
52
- * Ipc.new no longer accepts a block.
53
- * Changed IpcError to Ipc::Error.
54
- * Removed the 'doc' directory. The documentation is now inlined via rdoc.
55
- * Added a gemspec.
56
- * Added a Rakefile, including tasks for installation and testing.
57
-
58
- == 0.4.1 - 23-Jan-2005
59
- * Minor internal modifications for handling block arguments.
60
-
61
- == 0.4.0 - 16-Dec-2004
62
- * Changed the timeout from milliseconds to seconds. This wasn't documented,
63
- and I'm guessing most people didn't know that they were passing milliseconds
64
- instead of seconds. But, I've bumped the version number, just in case.
65
-
66
- == 0.3.1 - 11-Dec-2004
67
- * Fixed a bug in Ipc#wait where a segfault would occur if a block was not
68
- provided.
69
- * Moved the 'examples' directory to the toplevel directory.
70
-
71
- == 0.3.0 - 31-Oct-2004
72
- * The constructor now takes an optional block. Instance objects will call
73
- that block if they are signaled.
74
- * Added the 'block' method (read-only). Allows you to access the block
75
- provided to the constructor.
76
- * Modified the 'wait' instance method to take an optional block. This block
77
- will be called if the object is signaled. Overrides the block to the
78
- constructor for that instance object (only).
79
- * Added the 'signaled?' instance method to indicate if the object is in the
80
- signaled state or not.
81
- * Modified all methods to raise an IpcError if an error occurs (instead of
82
- simply returning nil).
83
- * Added internal comments in order to make the code rdoc friendly, including
84
- changes to the README file.
85
-
86
- == 0.2.0 - 15-Jul-2004
87
- * Updated to use the newer allocation framework. This means that as of
88
- version 0.2.0, this package requires Ruby 1.8.0 or later.
89
- * Moved the test.rb script to docs/examples.
90
- * Minor code cleanup
91
-
92
- == 0.1.0 - 30-Apr-2004
93
- * Initial release
1
+ == 0.7.0 - 22-Jun-2016
2
+ * The license is now Apache 2.0.
3
+
4
+ == 0.6.6 - 13-Sep-2015
5
+ * The gem is now signed.
6
+ * Added the win32-ipc.rb file for convenience.
7
+
8
+ == 0.6.5 - 7-Jul-2015
9
+ * Fixed the wait_for_multiple method for x64 platforms. Thanks go to Rafal
10
+ Bigaj for the spot and patch.
11
+
12
+ == 0.6.4 - 1-Jul-2015
13
+ * Fixed boolean argument type parameter. Thanks go to Rafal Bigaj for the patch.
14
+ * Updates to gemspec and Rakefile.
15
+
16
+ == 0.6.3 - 10-Jan-2015
17
+ * Declare the FFI prototype for WaitForSingleObject as blocking.
18
+
19
+ == 0.6.2 - 10-Jan-2015
20
+ * Declare the FFI prototype for WaitForMultipleObjects as blocking.
21
+
22
+ == 0.6.1 - 9-Apr-2013
23
+ * Updated the HANDLE function prototypes in the underlying FFI code. This
24
+ affects 64 bit versions of Ruby.
25
+
26
+ == 0.6.0 - 8-Jul-2012
27
+ * Now uses FFI instead of win32-api.
28
+ * The #signaled? method now has a meaningful default implementation.
29
+ * If an internal C function fails it raises a SystemCallError (Errno) instead
30
+ of an Ipc::Error.
31
+ * The Ipc::Error class, although defined for those who wish to still use it
32
+ in inherited classes, is no longer used internally.
33
+
34
+ == 0.5.3 - 19-Apr-2010
35
+ * Added a few gem related tasks to the Rakefile, and removed an old install
36
+ task.
37
+ * Removed the inline gem building code from the gemspec. That's now handled
38
+ by a Rake task.
39
+ * Some cosmetic changes to the source code.
40
+
41
+ == 0.5.2 - 6-Aug-2009
42
+ * License changed to Artistic 2.0.
43
+ * Some gemspec updates, including an updated description and adding a
44
+ license attribute.
45
+ * Renamed the test file to test_win32_ipc.rb.
46
+
47
+ == 0.5.1 - 1-Jan-2008
48
+ * Fixed bugs in the private wait_for_multiple method. Thanks go to an
49
+ anonymous user for the spot and the patch.
50
+ * Removed the install.rb file. Installation was merged into the Rakefile.
51
+ * Updated the MANIFEST.
52
+
53
+ == 0.5.0 - 30-Apr-2007
54
+ * Now pure Ruby.
55
+ * Ipc.new no longer accepts a block.
56
+ * Changed IpcError to Ipc::Error.
57
+ * Removed the 'doc' directory. The documentation is now inlined via rdoc.
58
+ * Added a gemspec.
59
+ * Added a Rakefile, including tasks for installation and testing.
60
+
61
+ == 0.4.1 - 23-Jan-2005
62
+ * Minor internal modifications for handling block arguments.
63
+
64
+ == 0.4.0 - 16-Dec-2004
65
+ * Changed the timeout from milliseconds to seconds. This wasn't documented,
66
+ and I'm guessing most people didn't know that they were passing milliseconds
67
+ instead of seconds. But, I've bumped the version number, just in case.
68
+
69
+ == 0.3.1 - 11-Dec-2004
70
+ * Fixed a bug in Ipc#wait where a segfault would occur if a block was not
71
+ provided.
72
+ * Moved the 'examples' directory to the toplevel directory.
73
+
74
+ == 0.3.0 - 31-Oct-2004
75
+ * The constructor now takes an optional block. Instance objects will call
76
+ that block if they are signaled.
77
+ * Added the 'block' method (read-only). Allows you to access the block
78
+ provided to the constructor.
79
+ * Modified the 'wait' instance method to take an optional block. This block
80
+ will be called if the object is signaled. Overrides the block to the
81
+ constructor for that instance object (only).
82
+ * Added the 'signaled?' instance method to indicate if the object is in the
83
+ signaled state or not.
84
+ * Modified all methods to raise an IpcError if an error occurs (instead of
85
+ simply returning nil).
86
+ * Added internal comments in order to make the code rdoc friendly, including
87
+ changes to the README file.
88
+
89
+ == 0.2.0 - 15-Jul-2004
90
+ * Updated to use the newer allocation framework. This means that as of
91
+ version 0.2.0, this package requires Ruby 1.8.0 or later.
92
+ * Moved the test.rb script to docs/examples.
93
+ * Minor code cleanup
94
+
95
+ == 0.1.0 - 30-Apr-2004
96
+ * Initial release
data/MANIFEST CHANGED
@@ -1,7 +1,8 @@
1
- * CHANGES
2
- * MANIFEST
3
- * README
4
- * Rakefile
5
- * win32-ipc.gemspec
6
- * lib/win32/ipc.rb
7
- * test/test_win32_ipc.rb
1
+ * CHANGES
2
+ * MANIFEST
3
+ * README
4
+ * Rakefile
5
+ * win32-ipc.gemspec
6
+ * certs/djberg96_pub.pem
7
+ * lib/win32/ipc.rb
8
+ * test/test_win32_ipc.rb
data/README CHANGED
@@ -1,33 +1,32 @@
1
- = Description
2
- An abstract base class for Windows synchronization objects.
3
-
4
- = Installation
5
- gem install win32-ipc
6
-
7
- = Synopsis
8
- There is no synopsis. Don't use this library directly. It is used as the basis
9
- for other libraries, such as win32-mutex, etc. Think of it as an interface.
10
-
11
- = Notes
12
- Originally based on the Win32::Ipc Perl module by Gurusamy Sarathy.
13
-
14
- This library is a prerequisite for several other IPC related Windows gems.
15
-
16
- = Known Bugs
17
- None that I know of. Please log any other bug reports on the project page
18
- at https://github.com/djberg96/win32-ipc.
19
-
20
- = License
21
- Artistic 2.0
22
-
23
- = Copyright
24
- (C) 2003-2015 Daniel J. Berger, All Rights Reserved
25
-
26
- = Warranty
27
- This package is provided "as is" and without any express or
28
- implied warranties, including, without limitation, the implied
29
- warranties of merchantability and fitness for a particular purpose.
30
-
31
- = Authors
32
- * Park Heesob
33
- * Daniel J. Berger
1
+ = Description
2
+ An abstract base class for Windows synchronization objects.
3
+
4
+ = Installation
5
+ gem install win32-ipc
6
+
7
+ = Synopsis
8
+ There is no synopsis. Don't use this library directly. It is used as the basis
9
+ for other libraries, such as win32-mutex, etc. Think of it as an interface.
10
+
11
+ = Notes
12
+ Originally based on the Win32::Ipc Perl module by Gurusamy Sarathy.
13
+ This library is a prerequisite for several other IPC related Windows gems.
14
+
15
+ = Known Bugs
16
+ None that I know of. Please log any bug reports on the project page
17
+ at https://github.com/djberg96/win32-ipc.
18
+
19
+ = License
20
+ Apache 2.0
21
+
22
+ = Copyright
23
+ (C) 2003-2016 Daniel J. Berger, All Rights Reserved
24
+
25
+ = Warranty
26
+ This package is provided "as is" and without any express or
27
+ implied warranties, including, without limitation, the implied
28
+ warranties of merchantability and fitness for a particular purpose.
29
+
30
+ = Authors
31
+ * Park Heesob
32
+ * Daniel J. Berger
data/Rakefile CHANGED
@@ -1,28 +1,28 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/clean'
4
-
5
- CLEAN.include("**/*.gem", "**/*.rbc")
6
-
7
- namespace 'gem' do
8
- desc 'Create the win32-ipc gem'
9
- task :create => [:clean] do
10
- require 'rubygems/package'
11
- spec = eval(IO.read('win32-ipc.gemspec'))
12
- spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
13
- Gem::Package.build(spec)
14
- end
15
-
16
- desc 'Install the win32-ipc gem'
17
- task :install => [:create] do
18
- file = Dir['*.gem'].first
19
- sh "gem install -l #{file}"
20
- end
21
- end
22
-
23
- Rake::TestTask.new do |t|
24
- t.verbose = true
25
- t.warning = true
26
- end
27
-
28
- task :default => :test
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/clean'
4
+
5
+ CLEAN.include("**/*.gem", "**/*.rbc")
6
+
7
+ namespace 'gem' do
8
+ desc 'Create the win32-ipc gem'
9
+ task :create => [:clean] do
10
+ require 'rubygems/package'
11
+ spec = eval(IO.read('win32-ipc.gemspec'))
12
+ spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
13
+ Gem::Package.build(spec, true)
14
+ end
15
+
16
+ desc 'Install the win32-ipc gem'
17
+ task :install => [:create] do
18
+ file = Dir['*.gem'].first
19
+ sh "gem install -l #{file}"
20
+ end
21
+ end
22
+
23
+ Rake::TestTask.new do |t|
24
+ t.verbose = true
25
+ t.warning = true
26
+ end
27
+
28
+ task :default => :test
@@ -1,21 +1,21 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
3
- cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
4
- MB4XDTE1MDkwMjIwNDkxOFoXDTE2MDkwMTIwNDkxOFowPzERMA8GA1UEAwwIZGpi
5
- ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
6
- bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMyTkvXqRp6hLs9eoJOS
7
- Hmi8kRYbq9Vkf15/hMxJpotYMgJVHHWrmDcC5Dye2PbnXjTkKf266Zw0PtT9h+lI
8
- S3ts9HO+vaCFSMwFFZmnWJSpQ3CNw2RcHxjWkk9yF7imEM8Kz9ojhiDXzBetdV6M
9
- gr0lV/alUr7TNVBDngbXEfTWscyXh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only.
4
- module Win32
5
-
6
- # This is a an abstract base class for IPC related classes, such as
7
- # Events and Semaphores.
8
- #
9
- class Ipc
10
- extend FFI::Library
11
- typedef :ulong, :dword
12
- typedef :uintptr_t, :handle
13
-
14
- ffi_lib :kernel32
15
-
16
- attach_function :CloseHandle, [:handle], :bool
17
- attach_function :WaitForSingleObject, [:handle, :dword], :dword, :blocking => true
18
- attach_function :WaitForMultipleObjects, [:dword, :pointer, :bool, :dword], :dword, :blocking => true
19
-
20
- private_class_method :CloseHandle, :WaitForSingleObject, :WaitForMultipleObjects
21
-
22
- # The version of the win32-ipc library
23
- VERSION = '0.6.6'
24
-
25
- SIGNALED = 1
26
- ABANDONED = -1
27
- TIMEOUT = 0
28
- INFINITE = 0xFFFFFFFF
29
-
30
- WAIT_OBJECT_0 = 0
31
- WAIT_TIMEOUT = 0x102
32
- WAIT_ABANDONED = 128
33
- WAIT_ABANDONED_0 = WAIT_ABANDONED
34
- WAIT_FAILED = 0xFFFFFFFF
35
-
36
- # The HANDLE object (an unsigned long value). Mostly provided for
37
- # subclasses to use internally when needed.
38
- #
39
- attr_reader :handle
40
-
41
- # Creates and returns a new IPC object. Since the IPC class is meant
42
- # as an abstract base class, you should never call this method directly.
43
- #
44
- def initialize(handle)
45
- @handle = handle
46
- @signaled = false
47
- end
48
-
49
- # Closes the handle object provided in the constructor.
50
- #
51
- def close
52
- CloseHandle(@handle)
53
- end
54
-
55
- # Returns whether or not the IPC object is in a signaled state.
56
- #--
57
- # This method assumes a single object. You may need to redefine this
58
- # to suit your needs in your subclass.
59
- #
60
- def signaled?
61
- state = WaitForSingleObject(@handle, 0)
62
-
63
- if state == WAIT_FAILED
64
- raise SystemCallError.new("WaitForSingleObject", FFI.errno)
65
- elsif state == WAIT_OBJECT_0
66
- @signaled = true
67
- else
68
- @signaled = false
69
- end
70
-
71
- @signaled
72
- end
73
-
74
- # call-seq:
75
- # Ipc#wait(timeout)
76
- # Ipc#wait(timeout){ block called when signaled }
77
- #
78
- # Waits for the calling object to be signaled. The +timeout+ value is
79
- # the maximum time to wait, in seconds. A timeout of 0 returns immediately.
80
- #
81
- # Returns SIGNALED (1), ABANDONED (-1) or TIMEOUT (0). Raises a
82
- # SystemCallError (Errno) if the wait fails for some reason.
83
- #
84
- def wait(timeout = INFINITE)
85
- timeout *= 1000 if timeout && timeout != INFINITE
86
-
87
- wait = WaitForSingleObject(@handle, timeout)
88
-
89
- case wait
90
- when WAIT_FAILED
91
- raise SystemCallError.new("WaitForSingleObject", FFI.errno)
92
- when WAIT_OBJECT_0
93
- @signaled = true
94
- yield if block_given?
95
- return SIGNALED
96
- when WAIT_ABANDONED
97
- return ABANDONED
98
- when WAIT_TIMEOUT
99
- return TIMEOUT
100
- else
101
- raise SystemCallError.new("WaitForSingleObject", FFI.errno)
102
- end
103
- end
104
-
105
- # :call-seq:
106
- # IPC#wait_any([ipc_objects], timeout = INFINITE)
107
- #
108
- # Waits for at least one of the +ipc_objects+ to be signaled. The
109
- # +timeout+ value is maximum time to wait in seconds. A timeout of 0
110
- # returns immediately.
111
- #
112
- # Returns the index+1 of the object that was signaled. If multiple
113
- # objects are signaled, the one with the lowest index is returned.
114
- # Returns 0 if no objects are signaled.
115
- #
116
- def wait_any(ipc_objects, timeout=INFINITE)
117
- timeout *= 1000 if timeout && timeout != INFINITE
118
- wait_for_multiple(ipc_objects, false, timeout)
119
- end
120
-
121
- # :call-seq:
122
- # IPC#wait_all([ipc_objects], timeout = INFINITE)
123
- #
124
- # Identical to IPC#wait_any, except that it waits for all +ipc_objects+
125
- # to be signaled instead of just one.
126
- #
127
- # Returns the index of the last object signaled. If at least one of the
128
- # objects is an abandoned mutex, the return value is negative.
129
- #
130
- def wait_all(ipc_objects, timeout=INFINITE)
131
- timeout *= 1000 if timeout && timeout != INFINITE
132
- wait_for_multiple(ipc_objects, true, timeout)
133
- end
134
-
135
- private
136
-
137
- # Waits until one or all (depending on the value of +wait_all+) of the
138
- # +ipc_objects+ are in the signaled state or the +timeout+ interval
139
- # elapses.
140
- #
141
- def wait_for_multiple(ipc_objects, wait_all=false, timeout=INFINITE)
142
- unless ipc_objects.is_a?(Array)
143
- msg = 'invalid argument - must be an array of Ipc objects'
144
- raise TypeError, msg
145
- end
146
-
147
- length = ipc_objects.size
148
-
149
- if length == 0
150
- raise ArgumentError, 'no objects to wait for'
151
- end
152
-
153
- ptr = FFI::MemoryPointer.new(:pointer, length)
154
-
155
- handles = ipc_objects.map(&:handle)
156
- ptr.write_array_of_pointer(handles)
157
-
158
- wait = WaitForMultipleObjects(
159
- length,
160
- ptr,
161
- wait_all,
162
- timeout
163
- )
164
-
165
- if wait == WAIT_FAILED
166
- raise SystemCallError.new("WaitForMultipleObjects", FFI.errno)
167
- end
168
-
169
- # signaled
170
- if (wait >= WAIT_OBJECT_0) && (wait < WAIT_OBJECT_0 + length)
171
- return wait - WAIT_OBJECT_0 + 1
172
- end
173
-
174
- # abandoned mutex - return negative value
175
- if (wait >= WAIT_ABANDONED) && (wait < WAIT_ABANDONED + length)
176
- return -wait - WAIT_ABANDONED + 1
177
- end
178
-
179
- # timed out
180
- return 0 if wait == WAIT_TIMEOUT
181
-
182
- nil
183
- end
184
- end
185
- end
1
+ require 'ffi'
2
+
3
+ # The Win32 module serves as a namespace only.
4
+ module Win32
5
+
6
+ # This is a an abstract base class for IPC related classes, such as
7
+ # Events and Semaphores.
8
+ #
9
+ class Ipc
10
+ extend FFI::Library
11
+ typedef :ulong, :dword
12
+ typedef :uintptr_t, :handle
13
+
14
+ ffi_lib :kernel32
15
+
16
+ attach_function :CloseHandle, [:handle], :bool
17
+ attach_function :WaitForSingleObject, [:handle, :dword], :dword, :blocking => true
18
+ attach_function :WaitForMultipleObjects, [:dword, :pointer, :bool, :dword], :dword, :blocking => true
19
+
20
+ private_class_method :CloseHandle, :WaitForSingleObject, :WaitForMultipleObjects
21
+
22
+ # The version of the win32-ipc library
23
+ VERSION = '0.7.0'
24
+
25
+ SIGNALED = 1
26
+ ABANDONED = -1
27
+ TIMEOUT = 0
28
+ INFINITE = 0xFFFFFFFF
29
+
30
+ WAIT_OBJECT_0 = 0
31
+ WAIT_TIMEOUT = 0x102
32
+ WAIT_ABANDONED = 128
33
+ WAIT_ABANDONED_0 = WAIT_ABANDONED
34
+ WAIT_FAILED = 0xFFFFFFFF
35
+
36
+ # The HANDLE object (an unsigned long value). Mostly provided for
37
+ # subclasses to use internally when needed.
38
+ #
39
+ attr_reader :handle
40
+
41
+ # Creates and returns a new IPC object. Since the IPC class is meant
42
+ # as an abstract base class, you should never call this method directly.
43
+ #
44
+ def initialize(handle)
45
+ @handle = handle
46
+ @signaled = false
47
+ end
48
+
49
+ # Closes the handle object provided in the constructor.
50
+ #
51
+ def close
52
+ CloseHandle(@handle)
53
+ end
54
+
55
+ # Returns whether or not the IPC object is in a signaled state.
56
+ #--
57
+ # This method assumes a single object. You may need to redefine this
58
+ # to suit your needs in your subclass.
59
+ #
60
+ def signaled?
61
+ state = WaitForSingleObject(@handle, 0)
62
+
63
+ if state == WAIT_FAILED
64
+ raise SystemCallError.new("WaitForSingleObject", FFI.errno)
65
+ elsif state == WAIT_OBJECT_0
66
+ @signaled = true
67
+ else
68
+ @signaled = false
69
+ end
70
+
71
+ @signaled
72
+ end
73
+
74
+ # call-seq:
75
+ # Ipc#wait(timeout)
76
+ # Ipc#wait(timeout){ block called when signaled }
77
+ #
78
+ # Waits for the calling object to be signaled. The +timeout+ value is
79
+ # the maximum time to wait, in seconds. A timeout of 0 returns immediately.
80
+ #
81
+ # Returns SIGNALED (1), ABANDONED (-1) or TIMEOUT (0). Raises a
82
+ # SystemCallError (Errno) if the wait fails for some reason.
83
+ #
84
+ def wait(timeout = INFINITE)
85
+ timeout *= 1000 if timeout && timeout != INFINITE
86
+
87
+ wait = WaitForSingleObject(@handle, timeout)
88
+
89
+ case wait
90
+ when WAIT_FAILED
91
+ raise SystemCallError.new("WaitForSingleObject", FFI.errno)
92
+ when WAIT_OBJECT_0
93
+ @signaled = true
94
+ yield if block_given?
95
+ return SIGNALED
96
+ when WAIT_ABANDONED
97
+ return ABANDONED
98
+ when WAIT_TIMEOUT
99
+ return TIMEOUT
100
+ else
101
+ raise SystemCallError.new("WaitForSingleObject", FFI.errno)
102
+ end
103
+ end
104
+
105
+ # :call-seq:
106
+ # IPC#wait_any([ipc_objects], timeout = INFINITE)
107
+ #
108
+ # Waits for at least one of the +ipc_objects+ to be signaled. The
109
+ # +timeout+ value is maximum time to wait in seconds. A timeout of 0
110
+ # returns immediately.
111
+ #
112
+ # Returns the index+1 of the object that was signaled. If multiple
113
+ # objects are signaled, the one with the lowest index is returned.
114
+ # Returns 0 if no objects are signaled.
115
+ #
116
+ def wait_any(ipc_objects, timeout=INFINITE)
117
+ timeout *= 1000 if timeout && timeout != INFINITE
118
+ wait_for_multiple(ipc_objects, false, timeout)
119
+ end
120
+
121
+ # :call-seq:
122
+ # IPC#wait_all([ipc_objects], timeout = INFINITE)
123
+ #
124
+ # Identical to IPC#wait_any, except that it waits for all +ipc_objects+
125
+ # to be signaled instead of just one.
126
+ #
127
+ # Returns the index of the last object signaled. If at least one of the
128
+ # objects is an abandoned mutex, the return value is negative.
129
+ #
130
+ def wait_all(ipc_objects, timeout=INFINITE)
131
+ timeout *= 1000 if timeout && timeout != INFINITE
132
+ wait_for_multiple(ipc_objects, true, timeout)
133
+ end
134
+
135
+ private
136
+
137
+ # Waits until one or all (depending on the value of +wait_all+) of the
138
+ # +ipc_objects+ are in the signaled state or the +timeout+ interval
139
+ # elapses.
140
+ #
141
+ def wait_for_multiple(ipc_objects, wait_all=false, timeout=INFINITE)
142
+ unless ipc_objects.is_a?(Array)
143
+ msg = 'invalid argument - must be an array of Ipc objects'
144
+ raise TypeError, msg
145
+ end
146
+
147
+ length = ipc_objects.size
148
+
149
+ if length == 0
150
+ raise ArgumentError, 'no objects to wait for'
151
+ end
152
+
153
+ ptr = FFI::MemoryPointer.new(:pointer, length)
154
+
155
+ handles = ipc_objects.map(&:handle)
156
+ ptr.write_array_of_pointer(handles)
157
+
158
+ wait = WaitForMultipleObjects(
159
+ length,
160
+ ptr,
161
+ wait_all,
162
+ timeout
163
+ )
164
+
165
+ if wait == WAIT_FAILED
166
+ raise SystemCallError.new("WaitForMultipleObjects", FFI.errno)
167
+ end
168
+
169
+ # signaled
170
+ if (wait >= WAIT_OBJECT_0) && (wait < WAIT_OBJECT_0 + length)
171
+ return wait - WAIT_OBJECT_0 + 1
172
+ end
173
+
174
+ # abandoned mutex - return negative value
175
+ if (wait >= WAIT_ABANDONED) && (wait < WAIT_ABANDONED + length)
176
+ return -wait - WAIT_ABANDONED + 1
177
+ end
178
+
179
+ # timed out
180
+ return 0 if wait == WAIT_TIMEOUT
181
+
182
+ nil
183
+ end
184
+ end
185
+ end
@@ -1,88 +1,88 @@
1
- ##########################################################################
2
- # test_win32_ipc.rb
3
- #
4
- # Test case for the Win32::Ipc class. Note that this class is rather
5
- # difficult to test directly since it is meant to be subclassed, not
6
- # used directly.
7
- #
8
- # You should run this test via the 'rake test' task.
9
- ##########################################################################
10
- require 'win32/ipc'
11
- require 'test-unit'
12
- include Win32
13
-
14
- class TC_Win32_Ipc < Test::Unit::TestCase
15
- def setup
16
- @ipc = Ipc.new(1)
17
- end
18
-
19
- test "version is set to expected value" do
20
- assert_equal('0.6.6', Ipc::VERSION)
21
- end
22
-
23
- test "handle method basic functionality" do
24
- assert_respond_to(@ipc, :handle)
25
- assert_equal(1, @ipc.handle)
26
- end
27
-
28
- test "signaled? method is defined" do
29
- assert_respond_to(@ipc, :signaled?)
30
- end
31
-
32
- test "wait method is defined" do
33
- assert_respond_to(@ipc, :wait)
34
- end
35
-
36
- test "wait raises ENXIO if handle is invalid" do
37
- assert_raises(Errno::ENXIO){ @ipc.wait }
38
- end
39
-
40
- test "wait accepts a maximum of one argument" do
41
- assert_raises(ArgumentError){ @ipc.wait(1,2) }
42
- end
43
-
44
- test "wait_any method is defined" do
45
- assert_respond_to(@ipc, :wait_any)
46
- end
47
-
48
- test "wait_any raises an ArgumentError if the array is empty" do
49
- assert_raises(ArgumentError){ @ipc.wait_any([]) }
50
- end
51
-
52
- test "wait_any only accepts an array" do
53
- assert_raises(TypeError){ @ipc.wait_any(1,2) }
54
- end
55
-
56
- test "wait_all method is defined" do
57
- assert_respond_to(@ipc, :wait_all)
58
- end
59
-
60
- test "wait_all raises an ArgumentError if the array is empty" do
61
- assert_raises(ArgumentError){ @ipc.wait_all([]) }
62
- end
63
-
64
- test "wait_all only accepts an array" do
65
- assert_raises(TypeError){ @ipc.wait_all(1,2) }
66
- end
67
-
68
- test "close method basic functionality" do
69
- assert_respond_to(@ipc, :close)
70
- assert_nothing_raised{ @ipc.close }
71
- end
72
-
73
- test "expected constants are defined" do
74
- assert_not_nil(Ipc::SIGNALED)
75
- assert_not_nil(Ipc::ABANDONED)
76
- assert_not_nil(Ipc::TIMEOUT)
77
- end
78
-
79
- test "ffi functions are private" do
80
- assert_not_respond_to(Ipc, :CloseHandle)
81
- assert_not_respond_to(Ipc, :WaitForSingleObject)
82
- assert_not_respond_to(Ipc, :WaitForMultipleObjects)
83
- end
84
-
85
- def teardown
86
- @ipc = nil
87
- end
88
- end
1
+ ##########################################################################
2
+ # test_win32_ipc.rb
3
+ #
4
+ # Test case for the Win32::Ipc class. Note that this class is rather
5
+ # difficult to test directly since it is meant to be subclassed, not
6
+ # used directly.
7
+ #
8
+ # You should run this test via the 'rake test' task.
9
+ ##########################################################################
10
+ require 'win32/ipc'
11
+ require 'test-unit'
12
+ include Win32
13
+
14
+ class TC_Win32_Ipc < Test::Unit::TestCase
15
+ def setup
16
+ @ipc = Ipc.new(1)
17
+ end
18
+
19
+ test "version is set to expected value" do
20
+ assert_equal('0.7.0', Ipc::VERSION)
21
+ end
22
+
23
+ test "handle method basic functionality" do
24
+ assert_respond_to(@ipc, :handle)
25
+ assert_equal(1, @ipc.handle)
26
+ end
27
+
28
+ test "signaled? method is defined" do
29
+ assert_respond_to(@ipc, :signaled?)
30
+ end
31
+
32
+ test "wait method is defined" do
33
+ assert_respond_to(@ipc, :wait)
34
+ end
35
+
36
+ test "wait raises ENXIO if handle is invalid" do
37
+ assert_raises(Errno::ENXIO){ @ipc.wait }
38
+ end
39
+
40
+ test "wait accepts a maximum of one argument" do
41
+ assert_raises(ArgumentError){ @ipc.wait(1,2) }
42
+ end
43
+
44
+ test "wait_any method is defined" do
45
+ assert_respond_to(@ipc, :wait_any)
46
+ end
47
+
48
+ test "wait_any raises an ArgumentError if the array is empty" do
49
+ assert_raises(ArgumentError){ @ipc.wait_any([]) }
50
+ end
51
+
52
+ test "wait_any only accepts an array" do
53
+ assert_raises(TypeError){ @ipc.wait_any(1,2) }
54
+ end
55
+
56
+ test "wait_all method is defined" do
57
+ assert_respond_to(@ipc, :wait_all)
58
+ end
59
+
60
+ test "wait_all raises an ArgumentError if the array is empty" do
61
+ assert_raises(ArgumentError){ @ipc.wait_all([]) }
62
+ end
63
+
64
+ test "wait_all only accepts an array" do
65
+ assert_raises(TypeError){ @ipc.wait_all(1,2) }
66
+ end
67
+
68
+ test "close method basic functionality" do
69
+ assert_respond_to(@ipc, :close)
70
+ assert_nothing_raised{ @ipc.close }
71
+ end
72
+
73
+ test "expected constants are defined" do
74
+ assert_not_nil(Ipc::SIGNALED)
75
+ assert_not_nil(Ipc::ABANDONED)
76
+ assert_not_nil(Ipc::TIMEOUT)
77
+ end
78
+
79
+ test "ffi functions are private" do
80
+ assert_not_respond_to(Ipc, :CloseHandle)
81
+ assert_not_respond_to(Ipc, :WaitForSingleObject)
82
+ assert_not_respond_to(Ipc, :WaitForMultipleObjects)
83
+ end
84
+
85
+ def teardown
86
+ @ipc = nil
87
+ end
88
+ end
@@ -1,25 +1,25 @@
1
- require 'rubygems'
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = 'win32-ipc'
5
- spec.version = '0.6.6'
6
- spec.authors = ['Daniel J. Berger', 'Park Heesob']
7
- spec.license = 'Artistic 2.0'
8
- spec.email = 'djberg96@gmail.com'
9
- spec.homepage = 'http://github.com/djberg96/win32-ipc'
10
- spec.summary = 'An abstract base class for Windows synchronization objects.'
11
- spec.test_file = 'test/test_win32_ipc.rb'
12
- spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
- spec.cert_chain = ['certs/djberg96_pub.pem']
14
-
15
- spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
16
-
17
- spec.add_dependency('ffi')
18
- spec.add_development_dependency('test-unit')
19
-
20
- spec.description = <<-EOF
21
- The win32-ipc library provides the Win32::IPC class. This is meant to
22
- serve as an abstract base class for other IPC related libraries for MS
23
- Windows, such as win32-semaphore, win32-event, and so on.
24
- EOF
25
- end
1
+ require 'rubygems'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'win32-ipc'
5
+ spec.version = '0.7.0'
6
+ spec.authors = ['Daniel J. Berger', 'Park Heesob']
7
+ spec.license = 'Apache 2.0'
8
+ spec.email = 'djberg96@gmail.com'
9
+ spec.homepage = 'http://github.com/djberg96/win32-ipc'
10
+ spec.summary = 'An abstract base class for Windows synchronization objects.'
11
+ spec.test_file = 'test/test_win32_ipc.rb'
12
+ spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
+ spec.cert_chain = ['certs/djberg96_pub.pem']
14
+
15
+ spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
16
+
17
+ spec.add_dependency('ffi')
18
+ spec.add_development_dependency('test-unit')
19
+
20
+ spec.description = <<-EOF
21
+ The win32-ipc library provides the Win32::IPC class. This is meant to
22
+ serve as an abstract base class for other IPC related libraries for MS
23
+ Windows, such as win32-semaphore, win32-event, and so on.
24
+ EOF
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-ipc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -31,7 +31,7 @@ cert_chain:
31
31
  EJYzxdPOrx2n6NYR3Hk+vHP0U7UBSveI6+qx+ndQYaeyCn+GRX2PKS9h66YF/Q1V
32
32
  tGSHgAmcLlkdGgan182qsE/4kKM=
33
33
  -----END CERTIFICATE-----
34
- date: 2015-09-13 00:00:00.000000000 Z
34
+ date: 2016-06-23 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ffi
@@ -73,18 +73,22 @@ extra_rdoc_files:
73
73
  - CHANGES
74
74
  - MANIFEST
75
75
  files:
76
+ - certs
77
+ - certs/djberg96_pub.pem
76
78
  - CHANGES
79
+ - lib
80
+ - lib/win32
81
+ - lib/win32/ipc.rb
82
+ - lib/win32-ipc.rb
77
83
  - MANIFEST
78
- - README
79
84
  - Rakefile
80
- - certs/djberg96_pub.pem
81
- - lib/win32-ipc.rb
82
- - lib/win32/ipc.rb
85
+ - README
86
+ - test
83
87
  - test/test_win32_ipc.rb
84
88
  - win32-ipc.gemspec
85
89
  homepage: http://github.com/djberg96/win32-ipc
86
90
  licenses:
87
- - Artistic 2.0
91
+ - Apache 2.0
88
92
  metadata: {}
89
93
  post_install_message:
90
94
  rdoc_options: []
@@ -102,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
106
  version: '0'
103
107
  requirements: []
104
108
  rubyforge_project:
105
- rubygems_version: 2.4.5
109
+ rubygems_version: 2.6.4
106
110
  signing_key:
107
111
  specification_version: 4
108
112
  summary: An abstract base class for Windows synchronization objects.
metadata.gz.sig CHANGED
Binary file