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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4684343b93a70e5ade31414a548044a4bdd67180
4
- data.tar.gz: 03463a0abb8c142b7832812a04915e98ddfdc825
3
+ metadata.gz: 43c80748fbbdc131f1949149a5046213b1d8ad4c
4
+ data.tar.gz: acd93be843908dead256dc96cb4680fa8f045abf
5
5
  SHA512:
6
- metadata.gz: 4996b7a36d757fc0f47961309a6b804c927de5ead7ff204914153f69e70a409f5e0a4d81761ac4d605b27182ccea259a6f71c6cfcdbf22237e22bb602ec0e371
7
- data.tar.gz: 2083fe220f4b7e3e9ba22a8a9f42a965546d0f8e2bc2f26ef500ca5d409980e1766775dc136ccd8079481e6c41649ccbe8e87fd03bb999c458bba46a71ca3bb8
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 = 512, // Max message size (bytes)
134
+ .mq_msgsize = 4096, // Max message size (bytes)
135
135
  .mq_curmsgs = 0 // # currently in queue
136
136
  };
137
137
 
@@ -1,5 +1,5 @@
1
1
  module POSIX
2
2
  class Mqueue
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
data/test/test_helper.rb CHANGED
@@ -3,4 +3,4 @@ require 'minitest/autorun'
3
3
 
4
4
  $: << File.dirname(__FILE__) + '/../ext'
5
5
 
6
- require "posix/mqueue/mqueue"
6
+ require "posix/mqueue"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posix-mqueue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Eskildsen