posix-mqueue 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +52 -0
- data/ext/posix/mqueue.c +1 -1
- data/lib/posix/mqueue/version.rb +1 -1
- data/test/test_helper.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: 43c80748fbbdc131f1949149a5046213b1d8ad4c
|
4
|
+
data.tar.gz: acd93be843908dead256dc96cb4680fa8f045abf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 764bb288fad4342bcc2bc99c69c5b5b1c12f2ee3f37367f5302f58eb1a8af285e2359fcd88a2c1db7ba4c183d857e87b77cab535285fc355bce47c78819d3427
|
7
|
+
data.tar.gz: 13506b7fabd6bee22da907f807bddd7bbdadc494e0d7a313e86c888048d0a2297e361a0728736763d248ba49b8a7dfcb190167ac6b44854c0d7a62c9af441f38
|
data/README.md
CHANGED
@@ -16,6 +16,8 @@ Still WIP. Not stable. Not everything works as promised.
|
|
16
16
|
## Usage
|
17
17
|
|
18
18
|
```ruby
|
19
|
+
require 'posix/mqueue'
|
20
|
+
|
19
21
|
m = POSIX::Mqueue.new("/whatever")
|
20
22
|
m.send "hello"
|
21
23
|
puts m.receive
|
@@ -28,4 +30,54 @@ m.receive
|
|
28
30
|
# => "world"
|
29
31
|
```
|
30
32
|
|
33
|
+
## mqueue
|
34
|
+
|
35
|
+
Most important information from the manpages, with a little added information
|
36
|
+
about the behavior of `posix-mqueue`.
|
37
|
+
|
38
|
+
## /proc interfaces
|
39
|
+
|
40
|
+
1. `/proc/sys/fs/mqueue/msg_max`. Contains the maximum number of messages in
|
41
|
+
queue. Defaults to 10. You should increase that number. `#send` will throw an
|
42
|
+
exception if the queue is full (instead of blocking).
|
43
|
+
2. `/proc/sys/fs/mqueue/msgsize_max`. Maximum size of a single message. Defaults
|
44
|
+
to 8192 bytes. `posix-mqueue` defaults to 4096 bytes. You'll be able to
|
45
|
+
change this, soon!
|
46
|
+
3. `/proc/sys/fs/mqueue/queues_max`. Maximum number of queues on the system.
|
47
|
+
Defaults to 256. Which is probably enough.
|
48
|
+
|
49
|
+
## Virtual filesystem
|
50
|
+
|
51
|
+
The message queue is created as a virtual file system. That means you can mount
|
52
|
+
it:
|
53
|
+
|
54
|
+
# sudo mkdir /dev/queue
|
55
|
+
# sudo mount -t mqueue none /dev/queue
|
56
|
+
|
57
|
+
Add a queue and a few tasks, count the characters and you'll see it's a total of 19 bytes:
|
58
|
+
|
59
|
+
$ irb
|
60
|
+
> require 'posix/mqueue'
|
61
|
+
=> true
|
62
|
+
> m = POSIX::Mqueue.new("/queue")
|
63
|
+
=> #<POSIX::Mqueue:0xb8c9fe88>
|
64
|
+
> m.send "narwhal"
|
65
|
+
=> true
|
66
|
+
> m.send "walrus"
|
67
|
+
=> true
|
68
|
+
> m.send "ponies"
|
69
|
+
=> true
|
70
|
+
> exit
|
71
|
+
|
72
|
+
Inspect the mounted filesystem:
|
73
|
+
|
74
|
+
$ ls /dev/queue/
|
75
|
+
important mails queue
|
76
|
+
$ cat /dev/queue/queue
|
77
|
+
QSIZE:19 NOTIFY:0 SIGNO:0 NOTIFY_PID:0
|
78
|
+
|
79
|
+
Here `QSIZE` is the bytes of data in the queue. The other flags are about
|
80
|
+
notifications which `posix-mqueue` does not support currently, read about them
|
81
|
+
in [mq_overview(7)][pmq].
|
82
|
+
|
31
83
|
[pmq]: http://man7.org/linux/man-pages/man7/mq_overview.7.html
|
data/ext/posix/mqueue.c
CHANGED
@@ -131,7 +131,7 @@ VALUE posix_mqueue_initialize(VALUE self, VALUE queue)
|
|
131
131
|
struct mq_attr attr = {
|
132
132
|
.mq_flags = 0, // Flags, 0 or O_NONBLOCK
|
133
133
|
.mq_maxmsg = 10, // Max messages in queue
|
134
|
-
.mq_msgsize =
|
134
|
+
.mq_msgsize = 4096, // Max message size (bytes)
|
135
135
|
.mq_curmsgs = 0 // # currently in queue
|
136
136
|
};
|
137
137
|
|
data/lib/posix/mqueue/version.rb
CHANGED
data/test/test_helper.rb
CHANGED