xchan.rb 0.16.4 → 0.16.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/README.md +14 -8
- data/lib/xchan/mixin.rb +1 -1
- data/lib/xchan/unix_socket.rb +3 -3
- data/lib/xchan/version.rb +1 -1
- data/share/xchan.rb/examples/write_operations/1_blocking_write.rb +1 -1
- data/share/xchan.rb/examples/write_operations/2_nonblocking_write.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5030f45f888a9c83fadde357be0c919cece744735af66016d80bcd5a9970dcc
|
4
|
+
data.tar.gz: b9de8383ad5af12a57586087c0c95b37d08ff07e7838b12471583c06ebec214b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6716dcd591f6384a8665e2601fcc10d17f7ecb2842ed656ffc13de90d785bf5bd2e089fcc2ef5bba2a58ebde0b544014cc769cec6315413d0ac7c32d99724930
|
7
|
+
data.tar.gz: 578c4aedba9104f7eeec52d1780df6ac7e7caed3040f19da4e4f20b436031e60f79ce2e7300e5ce6abbd6d638406143b5bcb0a4335b4400ae27cba05743f0db2
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -111,7 +111,7 @@ This example performs a write that will block when the send buffer becomes full:
|
|
111
111
|
```ruby
|
112
112
|
require "xchan"
|
113
113
|
|
114
|
-
ch = xchan(:marshal,
|
114
|
+
ch = xchan(:marshal, sock_type: Socket::SOCK_STREAM)
|
115
115
|
sndbuf = ch.getsockopt(:reader, Socket::SOL_SOCKET, Socket::SO_SNDBUF)
|
116
116
|
while ch.bytes_sent <= sndbuf.int
|
117
117
|
ch.send(1)
|
@@ -140,7 +140,7 @@ rescue Chan::WaitLockable
|
|
140
140
|
retry
|
141
141
|
end
|
142
142
|
|
143
|
-
ch = xchan(:marshal,
|
143
|
+
ch = xchan(:marshal, sock_type: Socket::SOCK_STREAM)
|
144
144
|
sndbuf = ch.getsockopt(:writer, Socket::SOL_SOCKET, Socket::SO_SNDBUF)
|
145
145
|
while ch.bytes_sent <= sndbuf.int
|
146
146
|
send_nonblock(ch, 1)
|
@@ -166,7 +166,7 @@ a keyword argument:
|
|
166
166
|
|
167
167
|
```ruby
|
168
168
|
require "xchan"
|
169
|
-
ch = xchan(:marshal,
|
169
|
+
ch = xchan(:marshal, sock_type: Socket::SOCK_STREAM)
|
170
170
|
```
|
171
171
|
|
172
172
|
#### Options
|
@@ -222,19 +222,25 @@ ch = xchan(:marshal, tmpdir: Dir.home)
|
|
222
222
|
|
223
223
|
## Install
|
224
224
|
|
225
|
+
**Git**
|
226
|
+
|
225
227
|
xchan.rb is distributed as a RubyGem through its git repositories. <br>
|
226
228
|
[GitHub](https://github.com/0x1eef/xchan.rb),
|
227
229
|
and
|
228
230
|
[GitLab](https://gitlab.com/0x1eef/xchan.rb)
|
229
231
|
are available as sources.
|
230
232
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
gem "xchan.rb", github: "0x1eef/xchan.rb", tag: "v0.16.3"
|
235
|
-
gem "lockf.rb", github: "0x1eef/lockf.rb", tag: "v0.10.6"
|
233
|
+
``` ruby
|
234
|
+
# Gemfile
|
235
|
+
gem "xchan.rb", github: "0x1eef/xchan.rb", tag: "v0.16.5"
|
236
236
|
```
|
237
237
|
|
238
|
+
**Rubygems.org**
|
239
|
+
|
240
|
+
xchan.rb can also be installed via rubygems.org.
|
241
|
+
|
242
|
+
gem install xchan.rb
|
243
|
+
|
238
244
|
## <a id="license"> License </a>
|
239
245
|
|
240
246
|
[BSD Zero Clause](https://choosealicense.com/licenses/0bsd/).
|
data/lib/xchan/mixin.rb
CHANGED
@@ -11,7 +11,7 @@ module Chan::Mixin
|
|
11
11
|
# ch.close
|
12
12
|
#
|
13
13
|
# @param serializer (see Chan::UNIXSocket#initialize)
|
14
|
-
# @param
|
14
|
+
# @param sock_type (see Chan::UNIXSocket#initialize)
|
15
15
|
# @param tmpdir (see Chan::UNIXSocket#initialize)
|
16
16
|
# @return (see Chan::UNIXSocket#initialize)
|
17
17
|
def xchan(serializer = :marshal, **kw_args)
|
data/lib/xchan/unix_socket.rb
CHANGED
@@ -18,7 +18,7 @@ class Chan::UNIXSocket
|
|
18
18
|
# @param [Symbol, <#dump, #load>] serializer
|
19
19
|
# A serializer.
|
20
20
|
#
|
21
|
-
# @param [Integer]
|
21
|
+
# @param [Integer] sock_type
|
22
22
|
# A socket type (eg Socket::SOCK_STREAM).
|
23
23
|
#
|
24
24
|
# @param [String] tmpdir
|
@@ -26,9 +26,9 @@ class Chan::UNIXSocket
|
|
26
26
|
#
|
27
27
|
# @return [Chan::UNIXSocket]
|
28
28
|
# Returns an instance of {Chan::UNIXSocket Chan::UNIXSocket}.
|
29
|
-
def initialize(serializer, tmpdir: Dir.tmpdir,
|
29
|
+
def initialize(serializer, tmpdir: Dir.tmpdir, sock_type: Socket::SOCK_DGRAM)
|
30
30
|
@serializer = Chan.serializers[serializer]&.call || serializer
|
31
|
-
@r, @w = ::UNIXSocket.pair(
|
31
|
+
@r, @w = ::UNIXSocket.pair(sock_type)
|
32
32
|
@bytes = Chan::Bytes.new(tmpdir)
|
33
33
|
@lock = LockFile.new Chan.temporary_file("xchan.lock", tmpdir:)
|
34
34
|
end
|
data/lib/xchan/version.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../setup"
|
4
4
|
require "xchan"
|
5
5
|
|
6
|
-
ch = xchan(:marshal,
|
6
|
+
ch = xchan(:marshal, sock_type: Socket::SOCK_STREAM)
|
7
7
|
sndbuf = ch.getsockopt(:reader, Socket::SOL_SOCKET, Socket::SO_SNDBUF)
|
8
8
|
while ch.bytes_sent <= sndbuf.int
|
9
9
|
ch.send(1)
|
@@ -14,7 +14,7 @@ rescue Chan::WaitLockable
|
|
14
14
|
retry
|
15
15
|
end
|
16
16
|
|
17
|
-
ch = xchan(:marshal,
|
17
|
+
ch = xchan(:marshal, sock_type: Socket::SOCK_STREAM)
|
18
18
|
sndbuf = ch.getsockopt(:writer, Socket::SOL_SOCKET, Socket::SO_SNDBUF)
|
19
19
|
while ch.bytes_sent <= sndbuf.int
|
20
20
|
send_nonblock(ch, 1)
|