Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: igrigorik/em-synchrony
base: 6f23d79b94
...
head fork: igrigorik/em-synchrony
compare: 13713b217a
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Commits on Sep 05, 2012
kostya kostya add em.system 1180854
Commits on Sep 06, 2012
Ilya Grigorik Merge pull request #134 from kostya/master
add em.system
13713b2
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
2  README.md
View
@@ -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:
8 lib/em-synchrony.rb
View
@@ -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
#
17 spec/system_spec.rb
View
@@ -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

No commit comments for this range

Something went wrong with that request. Please try again.