rxio 0.10.4 → 0.11.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/lib/rxio/service.rb +3 -14
- data/lib/rxio/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58ba254c8b92e99fce1f72e3e98f490f112ffbba
|
4
|
+
data.tar.gz: 64794413e4927e4b7380d5f87d20b7e3dbfe72fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3539209f39086919b411bf01ef6c5cb5acb8cf07afacdcc4e771509a996bd5421fafaf941ea3a07557f735a32d498132b4f05113d06338304963612ebc4b4703
|
7
|
+
data.tar.gz: 5906ac469b314c200ff95810c75073bf74be8c194e9acbd49ebd3270d62283301ddcc4d4ba612191a9c29ea90ab8e16ca749c20478a63779feb82733e1d2d1a4
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ A _stop_ method is also provided to request the service to terminate.
|
|
33
33
|
|
34
34
|
While the _run_ / _stop_ methods offer a simple way to implement a single service within the current thread, some situations may require the wrapping of the service in a separate thread.
|
35
35
|
|
36
|
-
|
36
|
+
Thank to [Runify](https://rubygems.org/gems/runify), a dedicated interface is provided for exactly this: _startup_ / _shutdown_ / _restart_
|
37
37
|
|
38
38
|
#### *startup*
|
39
39
|
|
@@ -41,9 +41,13 @@ Calling this method will spawn a new thread around the _run_ method, effectively
|
|
41
41
|
|
42
42
|
#### *shutdown*
|
43
43
|
|
44
|
-
Calling _shutdown_ will request the service to terminate
|
44
|
+
Calling _shutdown_ will request the service to terminate and wait for the thread to complete (join).
|
45
45
|
Once this method returns, the service has completely terminated (thread dead, all clients disconnected).
|
46
46
|
|
47
|
+
#### *restart*
|
48
|
+
|
49
|
+
This method is a simple shortcut to _shutdown_ immediately followed by _startup_.
|
50
|
+
|
47
51
|
### Handler Interface
|
48
52
|
|
49
53
|
The following is a list of methods that should be implemented by the handler module in order to provide a valid interface to the RxIO::Service class that will use it.
|
data/lib/rxio/service.rb
CHANGED
@@ -11,6 +11,9 @@ module RxIO
|
|
11
11
|
# Service Class
|
12
12
|
class Service
|
13
13
|
|
14
|
+
# Runify
|
15
|
+
include Runify
|
16
|
+
|
14
17
|
# Chunk Size
|
15
18
|
CHUNK_SIZE = 1024
|
16
19
|
|
@@ -38,20 +41,6 @@ module RxIO
|
|
38
41
|
@cmap = {}
|
39
42
|
end
|
40
43
|
|
41
|
-
# Start up
|
42
|
-
# Spawns a new Thread around the _run_ method to execute the service in the background.
|
43
|
-
def startup
|
44
|
-
@thread = Thread.new { run }
|
45
|
-
end
|
46
|
-
|
47
|
-
# Shutdown
|
48
|
-
# Gracefully terminates the service, waiting for all resources to be released (returns once the service thread has completed).
|
49
|
-
def shutdown
|
50
|
-
@stop = true
|
51
|
-
@thread.join
|
52
|
-
@thread = nil
|
53
|
-
end
|
54
|
-
|
55
44
|
# Run
|
56
45
|
# Executes the main service loop, taking care of I/O scheduling, client management and message handling.
|
57
46
|
# Note: this method blocks until the service loop terminates.
|
data/lib/rxio/version.rb
CHANGED