Permalink
Browse files

initial checkin

  • Loading branch information...
0 parents commit 6eaff7c1918acd44b0eed375d1c74e07204e06bf @tenderlove committed Sep 22, 2008
Showing with 61,388 additions and 0 deletions.
  1. +12 −0 .gitignore
  2. +6 −0 History.txt
  3. +7 −0 Manifest.txt
  4. +48 −0 README.txt
  5. +11 −0 Rakefile
  6. 0 bin/quail
  7. +3 −0 lib/quail.rb
  8. 0 test/test_quail.rb
  9. +122 −0 vendor/czmq/czmq.cpp
  10. +27 −0 vendor/czmq/czmq.h
  11. +86 −0 vendor/czmq/local_lat.c
  12. +90 −0 vendor/czmq/local_thr.c
  13. +55 −0 vendor/czmq/remote_lat.c
  14. +58 −0 vendor/czmq/remote_thr.c
  15. +18 −0 vendor/zmq-0.3/AUTHORS
  16. +674 −0 vendor/zmq-0.3/COPYING
  17. 0 vendor/zmq-0.3/ChangeLog
  18. +236 −0 vendor/zmq-0.3/INSTALL
  19. +14 −0 vendor/zmq-0.3/Makefile.am
  20. +624 −0 vendor/zmq-0.3/Makefile.in
  21. 0 vendor/zmq-0.3/NEWS
  22. +4 −0 vendor/zmq-0.3/README
  23. +7,389 −0 vendor/zmq-0.3/aclocal.m4
  24. +1,500 −0 vendor/zmq-0.3/config/config.guess
  25. +1,608 −0 vendor/zmq-0.3/config/config.sub
  26. +530 −0 vendor/zmq-0.3/config/depcomp
  27. +323 −0 vendor/zmq-0.3/config/install-sh
  28. +6,871 −0 vendor/zmq-0.3/config/ltmain.sh
  29. +360 −0 vendor/zmq-0.3/config/missing
  30. +23,371 −0 vendor/zmq-0.3/configure
  31. +198 −0 vendor/zmq-0.3/configure.in
  32. +14 −0 vendor/zmq-0.3/examples/Makefile.am
  33. +494 −0 vendor/zmq-0.3/examples/Makefile.in
  34. +15 −0 vendor/zmq-0.3/examples/camera/Makefile.am
  35. +495 −0 vendor/zmq-0.3/examples/camera/Makefile.in
  36. +18 −0 vendor/zmq-0.3/examples/camera/README
  37. +144 −0 vendor/zmq-0.3/examples/camera/receiver.cpp
  38. +192 −0 vendor/zmq-0.3/examples/camera/sender.cpp
  39. +488 −0 vendor/zmq-0.3/examples/camera/ucil.h
  40. +16 −0 vendor/zmq-0.3/examples/chat/Makefile.am
  41. +510 −0 vendor/zmq-0.3/examples/chat/Makefile.in
  42. +98 −0 vendor/zmq-0.3/examples/chat/chatroom.cpp
  43. +70 −0 vendor/zmq-0.3/examples/chat/display.cpp
  44. +79 −0 vendor/zmq-0.3/examples/chat/prompt.cpp
  45. +20 −0 vendor/zmq-0.3/examples/exchange/Makefile.am
  46. +524 −0 vendor/zmq-0.3/examples/exchange/Makefile.in
  47. +34 −0 vendor/zmq-0.3/examples/exchange/common.hpp
  48. +91 −0 vendor/zmq-0.3/examples/exchange/frequency_meter.hpp
  49. +161 −0 vendor/zmq-0.3/examples/exchange/graph.pl
  50. +259 −0 vendor/zmq-0.3/examples/exchange/gtw.cpp
  51. +267 −0 vendor/zmq-0.3/examples/exchange/matching_engine.hpp
  52. +170 −0 vendor/zmq-0.3/examples/exchange/me.cpp
  53. +212 −0 vendor/zmq-0.3/examples/exchange/messages.hpp
  54. +130 −0 vendor/zmq-0.3/examples/exchange/stat.cpp
  55. +1 −0 vendor/zmq-0.3/perf/Makefile.am
  56. +491 −0 vendor/zmq-0.3/perf/Makefile.in
  57. +7 −0 vendor/zmq-0.3/perf/helpers/Makefile.am
  58. +459 −0 vendor/zmq-0.3/perf/helpers/Makefile.in
  59. +46 −0 vendor/zmq-0.3/perf/helpers/estimate_cpu_freq.cpp
  60. +36 −0 vendor/zmq-0.3/perf/helpers/functions.hpp
  61. +81 −0 vendor/zmq-0.3/perf/helpers/ticker.hpp
  62. +151 −0 vendor/zmq-0.3/perf/helpers/time.hpp
  63. +1 −0 vendor/zmq-0.3/perf/tests/Makefile.am
  64. +491 −0 vendor/zmq-0.3/perf/tests/Makefile.in
  65. +155 −0 vendor/zmq-0.3/perf/tests/scenarios/fi.hpp
  66. +93 −0 vendor/zmq-0.3/perf/tests/scenarios/fi.sh
  67. +164 −0 vendor/zmq-0.3/perf/tests/scenarios/fo.hpp
  68. +93 −0 vendor/zmq-0.3/perf/tests/scenarios/fo.sh
  69. +147 −0 vendor/zmq-0.3/perf/tests/scenarios/lat.hpp
  70. +113 −0 vendor/zmq-0.3/perf/tests/scenarios/lat.sh
  71. +239 −0 vendor/zmq-0.3/perf/tests/scenarios/thr.hpp
  72. +111 −0 vendor/zmq-0.3/perf/tests/scenarios/thr.sh
  73. +160 −0 vendor/zmq-0.3/perf/tests/scenarios/thr_lat.hpp
  74. +18 −0 vendor/zmq-0.3/perf/tests/tcp/Makefile.am
  75. +545 −0 vendor/zmq-0.3/perf/tests/tcp/Makefile.in
  76. +54 −0 vendor/zmq-0.3/perf/tests/tcp/local_lat.cpp
  77. +73 −0 vendor/zmq-0.3/perf/tests/tcp/local_thr.cpp
  78. +53 −0 vendor/zmq-0.3/perf/tests/tcp/remote_lat.cpp
  79. +75 −0 vendor/zmq-0.3/perf/tests/tcp/remote_thr.cpp
  80. +62 −0 vendor/zmq-0.3/perf/tests/zmq/Makefile.am
  81. +722 −0 vendor/zmq-0.3/perf/tests/zmq/Makefile.in
  82. +57 −0 vendor/zmq-0.3/perf/tests/zmq/local_fi.cpp
  83. +58 −0 vendor/zmq-0.3/perf/tests/zmq/local_fo.cpp
  84. +54 −0 vendor/zmq-0.3/perf/tests/zmq/local_lat.cpp
  85. +92 −0 vendor/zmq-0.3/perf/tests/zmq/local_thr.cpp
  86. +53 −0 vendor/zmq-0.3/perf/tests/zmq/local_thr_lat.cpp
  87. +54 −0 vendor/zmq-0.3/perf/tests/zmq/remote_fi.cpp
  88. +56 −0 vendor/zmq-0.3/perf/tests/zmq/remote_fo.cpp
  89. +51 −0 vendor/zmq-0.3/perf/tests/zmq/remote_lat.cpp
  90. +83 −0 vendor/zmq-0.3/perf/tests/zmq/remote_thr.cpp
  91. +54 −0 vendor/zmq-0.3/perf/tests/zmq/remote_thr_lat.cpp
  92. +43 −0 vendor/zmq-0.3/perf/transports/i_transport.hpp
  93. +166 −0 vendor/zmq-0.3/perf/transports/tcp.hpp
  94. +110 −0 vendor/zmq-0.3/perf/transports/zmq.hpp
  95. +75 −0 vendor/zmq-0.3/zmq/Makefile.am
  96. +797 −0 vendor/zmq-0.3/zmq/Makefile.in
  97. +396 −0 vendor/zmq-0.3/zmq/api_thread.cpp
  98. +152 −0 vendor/zmq-0.3/zmq/api_thread.hpp
  99. +183 −0 vendor/zmq-0.3/zmq/atomic_bitmap.hpp
  100. +122 −0 vendor/zmq-0.3/zmq/atomic_counter.hpp
  101. +141 −0 vendor/zmq-0.3/zmq/atomic_ptr.hpp
  102. +58 −0 vendor/zmq-0.3/zmq/bp_decoder.cpp
  103. +50 −0 vendor/zmq-0.3/zmq/bp_decoder.hpp
  104. +60 −0 vendor/zmq-0.3/zmq/bp_encoder.cpp
  105. +53 −0 vendor/zmq-0.3/zmq/bp_encoder.hpp
  106. +221 −0 vendor/zmq-0.3/zmq/bp_engine.cpp
  107. +123 −0 vendor/zmq-0.3/zmq/bp_engine.hpp
  108. +162 −0 vendor/zmq-0.3/zmq/bp_listener.cpp
  109. +92 −0 vendor/zmq-0.3/zmq/bp_listener.hpp
  110. +156 −0 vendor/zmq-0.3/zmq/command.hpp
  111. +162 −0 vendor/zmq-0.3/zmq/config.h.in
  112. +68 −0 vendor/zmq-0.3/zmq/config.hpp
  113. +95 −0 vendor/zmq-0.3/zmq/decoder.hpp
  114. +119 −0 vendor/zmq-0.3/zmq/demux.cpp
  115. +66 −0 vendor/zmq-0.3/zmq/demux.hpp
  116. +118 −0 vendor/zmq-0.3/zmq/dispatcher.cpp
  117. +146 −0 vendor/zmq-0.3/zmq/dispatcher.hpp
  118. +87 −0 vendor/zmq-0.3/zmq/encoder.hpp
  119. +44 −0 vendor/zmq-0.3/zmq/err.hpp
  120. +48 −0 vendor/zmq-0.3/zmq/i_context.hpp
  121. +44 −0 vendor/zmq-0.3/zmq/i_engine.hpp
  122. +67 −0 vendor/zmq-0.3/zmq/i_locator.hpp
  123. +52 −0 vendor/zmq-0.3/zmq/i_pollable.hpp
  124. +39 −0 vendor/zmq-0.3/zmq/i_signaler.hpp
  125. +274 −0 vendor/zmq-0.3/zmq/locator.cpp
  126. +114 −0 vendor/zmq-0.3/zmq/locator.hpp
  127. +120 −0 vendor/zmq-0.3/zmq/message.hpp
  128. +74 −0 vendor/zmq-0.3/zmq/mux.cpp
  129. +64 −0 vendor/zmq-0.3/zmq/mux.hpp
  130. +85 −0 vendor/zmq-0.3/zmq/pipe.cpp
  131. +106 −0 vendor/zmq-0.3/zmq/pipe.hpp
  132. +12 −0 vendor/zmq-0.3/zmq/platform.hpp.in
  133. +238 −0 vendor/zmq-0.3/zmq/poll_thread.cpp
  134. +99 −0 vendor/zmq-0.3/zmq/poll_thread.hpp
  135. +193 −0 vendor/zmq-0.3/zmq/raw_message.hpp
  136. +43 −0 vendor/zmq-0.3/zmq/scope.hpp
  137. +12 −0 vendor/zmq-0.3/zmq/stdint.hpp.in
  138. +118 −0 vendor/zmq-0.3/zmq/tcp_listener.cpp
  139. +66 −0 vendor/zmq-0.3/zmq/tcp_listener.hpp
  140. +104 −0 vendor/zmq-0.3/zmq/tcp_socket.cpp
  141. +75 −0 vendor/zmq-0.3/zmq/tcp_socket.hpp
  142. +98 −0 vendor/zmq-0.3/zmq/wire.hpp
  143. +184 −0 vendor/zmq-0.3/zmq/ypipe.hpp
  144. +27 −0 vendor/zmq-0.3/zmq/ypollset.cpp
  145. +99 −0 vendor/zmq-0.3/zmq/ypollset.hpp
  146. +133 −0 vendor/zmq-0.3/zmq/yqueue.hpp
  147. +41 −0 vendor/zmq-0.3/zmq/ysemaphore.cpp
  148. +136 −0 vendor/zmq-0.3/zmq/ysemaphore.hpp
  149. +28 −0 vendor/zmq-0.3/zmq/ysocketpair.cpp
  150. +109 −0 vendor/zmq-0.3/zmq/ysocketpair.hpp
  151. +378 −0 vendor/zmq-0.3/zmq/zmq_server.cpp
  152. +44 −0 vendor/zmq-0.3/zmq/zmq_server.hpp
@@ -0,0 +1,12 @@
+.*.swp
+*.tmproj
+ext/nokogiri/*.o
+ext/nokogiri/Makefile
+ext/nokogiri/*.log
+ext/nokogiri/*.bundle
+ext/nokogiri/*.a
+ext/nokogiri/*.so
+ext/nokogiri/conftest.dSYM
+lib/nokogiri/css/generated_parser.rb
+lib/nokogiri/css/generated_tokenizer.rb
+tags
@@ -0,0 +1,6 @@
+=== 1.0.0 / 2008-09-22
+
+* 1 major enhancement
+
+ * Birthday!
+
@@ -0,0 +1,7 @@
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+bin/quail
+lib/quail.rb
+test/test_quail.rb
@@ -0,0 +1,48 @@
+= quail
+
+* FIX (url)
+
+== DESCRIPTION:
+
+FIX (describe your package)
+
+== FEATURES/PROBLEMS:
+
+* FIX (list of features or problems)
+
+== SYNOPSIS:
+
+ FIX (code sample of usage)
+
+== REQUIREMENTS:
+
+* FIX (list of requirements)
+
+== INSTALL:
+
+* FIX (sudo gem install, anything else)
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2008 FIX
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,11 @@
+# -*- ruby -*-
+
+require 'rubygems'
+require 'hoe'
+require './lib/quail.rb'
+
+Hoe.new('quail', Quail::VERSION) do |p|
+ p.developer('Aaron Patterson', 'aaronp@rubyforge.org')
+end
+
+# vim: syntax=Ruby
No changes.
@@ -0,0 +1,3 @@
+class Quail
+ VERSION = '1.0.0'
+end
No changes.
@@ -0,0 +1,122 @@
+
+#include "czmq.h"
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <zmq/message.hpp>
+#include <zmq/locator.hpp>
+#include <zmq/dispatcher.hpp>
+#include <zmq/poll_thread.hpp>
+#include <zmq/api_thread.hpp>
+
+struct context_t
+{
+ zmq::locator_t *locator;
+ zmq::dispatcher_t *dispatcher;
+ zmq::poll_thread_t *poll_thread;
+ zmq::api_thread_t *api_thread;
+};
+
+void *czmq_create (const char *host_)
+{
+ // Create the context.
+ context_t *context = new context_t;
+ assert (context);
+ context->locator = new zmq::locator_t (host_);
+ assert (context->locator);
+ context->dispatcher = new zmq::dispatcher_t (2);
+ assert (context->dispatcher);
+ context->poll_thread = zmq::poll_thread_t::create (context->dispatcher);
+ assert (context->poll_thread);
+ context->api_thread = zmq::api_thread_t::create (context->dispatcher,
+ context->locator);
+ assert (context->api_thread);
+
+ return (void*) context;
+}
+
+void czmq_destroy (void *obj_)
+{
+ // Get the context.
+ context_t *context = (context_t*) obj_;
+
+ // Deallocate the 0MQ infrastructure.
+ delete context->dispatcher;
+ delete context->locator;
+ delete context;
+}
+
+int czmq_create_exchange (void *obj_, const char *exchange_, int scope_,
+ const char *nic_)
+{
+ // Get the context.
+ context_t *context = (context_t*) obj_;
+
+ // Get the scope.
+ zmq::scope_t scope = zmq::scope_local;
+ if (scope_ == CZMQ_SCOPE_GLOBAL)
+ scope = zmq::scope_global;
+
+ // Forward the call to native 0MQ library.
+ return context->api_thread->create_exchange (exchange_, scope, nic_,
+ context->poll_thread, 1, &context->poll_thread);
+}
+
+int czmq_create_queue (void *obj_, const char *queue_, int scope_,
+ const char *nic_)
+{
+ // Get the context.
+ context_t *context = (context_t*) obj_;
+
+ // Get the scope.
+ zmq::scope_t scope = zmq::scope_local;
+ if (scope_ == CZMQ_SCOPE_GLOBAL)
+ scope = zmq::scope_global;
+
+ // Forward the call to native 0MQ library.
+ return context->api_thread->create_queue (queue_, scope, nic_,
+ context->poll_thread, 1, &context->poll_thread);
+}
+
+void czmq_bind (void *obj_, const char *exchange_, const char *queue_)
+{
+ // Get the context.
+ context_t *context = (context_t*) obj_;
+
+ // Forward the call to native 0MQ library.
+ context->api_thread->bind (exchange_, queue_,
+ context->poll_thread, context->poll_thread);
+}
+
+void czmq_send (void *obj_, int eid_, void *data_, size_t size_,
+ czmq_free_fn *ffn_)
+{
+ // Get the context.
+ context_t *context = (context_t*) obj_;
+
+ // Forward the call to native 0MQ library.
+ zmq::message_t msg (data_, size_, ffn_);
+ context->api_thread->send (eid_, msg);
+}
+
+void czmq_receive (void *obj_, void **data_, size_t *size_, czmq_free_fn **ffn_)
+{
+ // Get the context.
+ context_t *context = (context_t*) obj_;
+
+ // Forward the call to native 0MQ library.
+ zmq::message_t msg;
+ context->api_thread->receive (&msg);
+
+ // Create a buffer and copy the data into it.
+ void *buf = malloc (msg.size ());
+ assert (buf);
+ memcpy (buf, msg.data (), msg.size ());
+
+ // Return the message.
+ *data_ = buf;
+ *size_ = msg.size ();
+ *ffn_ = free;
+}
@@ -0,0 +1,27 @@
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CZMQ_SCOPE_LOCAL 0
+#define CZMQ_SCOPE_GLOBAL 1
+
+typedef void (czmq_free_fn) (void *data_);
+
+void *czmq_create (const char *host_);
+void czmq_destroy (void *obj_);
+int czmq_create_exchange (void *obj_, const char *exchange_, int scope_,
+ const char *nic_);
+int czmq_create_queue (void *obj_, const char *queue_, int scope_,
+ const char *nic_);
+void czmq_bind (void *obj_, const char *exchange_, const char *queue_);
+void czmq_send (void *obj_, int eid_, void *data_, size_t size,
+ czmq_free_fn *ffn_);
+void czmq_receive (void *obj_, void **data_, size_t *size_,
+ czmq_free_fn **ffn_);
+
+#ifdef __cplusplus
+}
+#endif
@@ -0,0 +1,86 @@
+
+#include <stddef.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <sys/time.h>
+
+#include "czmq.h"
+
+inline uint64_t now_usecs ()
+{
+ struct timeval tv;
+ int rc;
+
+ rc = gettimeofday (&tv, NULL);
+ assert (rc == 0);
+ return tv.tv_sec * (uint64_t) 1000000 + tv.tv_usec;
+}
+
+int main (int argc, char *argv [])
+{
+ const char *host;
+ int message_size;
+ int roundtrip_count;
+ void *handle;
+ int eid;
+ int counter;
+ void *out_buf;
+ void *in_buf;
+ size_t in_size;
+ czmq_free_fn *in_ffn;
+
+ // Parse command line arguments.
+ if (argc != 4) {
+ printf ("usage: local_lat <hostname> <message-size> "
+ "<roundtrip-count>\n");
+ return 1;
+ }
+ host = argv [1];
+ message_size = atoi (argv [2]);
+ roundtrip_count = atoi (argv [3]);
+
+ // Print out the test parameters.
+ printf ("message size: %d [B]\n", message_size);
+ printf ("roundtrip count: %d\n", roundtrip_count);
+
+ // Create 0MQ transport.
+ handle = czmq_create (host);
+
+ // Create the wiring.
+ eid = czmq_create_exchange (handle, "EL", CZMQ_SCOPE_LOCAL, NULL);
+ czmq_create_queue (handle, "QL", CZMQ_SCOPE_LOCAL, NULL);
+ czmq_bind (handle, "EL", "QG");
+ czmq_bind (handle, "EG", "QL");
+
+ // Create message data to send.
+ out_buf = malloc (message_size);
+ assert (out_buf);
+
+ // Get initial timestamp.
+ uint64_t start = now_usecs ();
+
+ for (counter = 0; counter != roundtrip_count; counter ++) {
+ czmq_send (handle, eid, out_buf, message_size, NULL);
+ czmq_receive (handle, &in_buf, &in_size, &in_ffn);
+ assert (in_size == message_size);
+ if (in_ffn)
+ in_ffn (in_buf);
+ }
+
+ // Get final timestamp.
+ uint64_t end = now_usecs ();
+
+ // Compute and print out the latency.
+ double latency = (double) (end - start) / roundtrip_count / 2;
+ printf ("Your average latency is %.2lf [us]\n", latency);
+
+ // Destroy 0MQ transport.
+ czmq_destroy (handle);
+
+ // Clean up.
+ free (out_buf);
+
+ return 0;
+}
Oops, something went wrong.

0 comments on commit 6eaff7c

Please sign in to comment.