asynchronous 1.0.1 → 1.0.2
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.
- data/README.md +24 -9
- data/VERSION +1 -1
- data/lib/asynchronous/kernel.rb +4 -2
- metadata +2 -2
data/README.md
CHANGED
@@ -5,10 +5,29 @@ Asynchronous Patterns for Ruby Based on Pure MRI CRuby code
|
|
5
5
|
The goal is to use the original MRI C libs for achive
|
6
6
|
real async patterns in ruby
|
7
7
|
|
8
|
-
Well it is achived
|
8
|
+
Well it is achived in Ruby really simple, and elegant way.
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
## Quoting Sun's Multithreaded Programming Guide:
|
12
|
+
|
13
|
+
Parallelism:
|
14
|
+
- A condition that arises when at least two threads are executing simultaneously.
|
15
|
+
|
16
|
+
Concurrency:
|
17
|
+
- A condition that exists when at least two threads are making progress.
|
18
|
+
- A more generalized form of parallelism that can include time-slicing as a form of virtual parallelism
|
19
|
+
|
20
|
+
### for short:
|
21
|
+
|
22
|
+
Concurrency is when two tasks can start, run, and complete in overlapping time periods.
|
23
|
+
It doesn't necessarily mean they'll ever both be running at the same instant.
|
24
|
+
Eg. multitasking on a single-core machine.
|
25
|
+
|
26
|
+
Parallelism is when tasks literally run at the same time.
|
27
|
+
Eg. on a multicore processor.
|
28
|
+
|
29
|
+
|
30
|
+
## OS managed thread (Native Threads)
|
12
31
|
|
13
32
|
copy on write memory share,
|
14
33
|
so you cant change anything in the mother process
|
@@ -37,7 +56,7 @@ calculation.value
|
|
37
56
|
|
38
57
|
```
|
39
58
|
|
40
|
-
|
59
|
+
## VM managed thread (Green Threads)
|
41
60
|
|
42
61
|
you can use simple :c also instead of :concurrency as sym,
|
43
62
|
remember :concurrency is all about GIL case, so
|
@@ -56,13 +75,9 @@ calculation.value
|
|
56
75
|
```
|
57
76
|
# Examples
|
58
77
|
|
59
|
-
the "
|
78
|
+
the "async patterns" will let you see how easy to use threads
|
60
79
|
for multiprocessing so you can give multiple task to do and
|
61
|
-
until you
|
62
|
-
You can also use OS threads instead of VM Threads for real Parallelism
|
63
|
-
|
64
|
-
the "require_files" shows you how can you get files from directory
|
65
|
-
in a recursive way and stuffs like that so you can be lay
|
80
|
+
until you need they value, let the process run in the background
|
66
81
|
|
67
82
|
## LICENSE
|
68
83
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/lib/asynchronous/kernel.rb
CHANGED
@@ -14,11 +14,13 @@ module Kernel
|
|
14
14
|
def async(type= :Concurrency ,&block)
|
15
15
|
type= type.to_s
|
16
16
|
case type.downcase[0]
|
17
|
-
|
17
|
+
# Concurrency / VM / Green
|
18
|
+
when "c","v","g"
|
18
19
|
begin
|
19
20
|
Asynchronous::Concurrency.new(block)
|
20
21
|
end
|
21
|
-
|
22
|
+
# Parallelism / OS / Native
|
23
|
+
when "p","o","n"
|
22
24
|
begin
|
23
25
|
Asynchronous::Parallelism.new(block)
|
24
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asynchronous
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'DSL for for dead simple to use asynchronous patterns in both VM managed
|
15
15
|
and OS managed way (Concurrency and Parallelism) '
|