Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #134 from kostya/master

add em.system
  • Loading branch information...
commit 13713b217ac1d74168464f68702fdbb27cb08028 2 parents 6f23d79 + 1180854
@igrigorik authored
Showing with 26 additions and 1 deletion.
  1. +1 −1  README.md
  2. +8 −0 lib/em-synchrony.rb
  3. +17 −0 spec/system_spec.rb
View
2  README.md
@@ -8,7 +8,7 @@ Collection of convenience classes and primitives to help untangle evented code,
* Fiber aware Multi-request interface for any callback enabled clients
* Fiber aware TCPSocket replacement, powered by EventMachine
* Fiber aware Thread, Mutex, ConditionVariable clases
- * Fiber aware sleep, defer
+ * Fiber aware sleep, defer, system
Supported clients:
View
8 lib/em-synchrony.rb
@@ -106,6 +106,14 @@ def self.defer op = nil, &blk
EM.defer(op || blk, lambda{ |result| fiber.resume(result) })
Fiber.yield
end
+
+ # Fiber-aware EM.system
+ #
+ def self.system cmd, *args
+ fiber = Fiber.current
+ EM.system(cmd, *args){ |out, status| fiber.resume( [out, status] ) }
+ Fiber.yield
+ end
# Routes to EM::Synchrony::Keyboard
#
View
17 spec/system_spec.rb
@@ -0,0 +1,17 @@
+require "spec/helper/all"
+
+describe EventMachine::Synchrony do
+
+ it "system: simple" do
+ EM.synchrony do
+ out, status = EM::Synchrony.system("echo 'some'")
+
+ status.should == 0
+ out.should == "some\n"
+
+ EM.stop
+ end
+ end
+
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.