Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, 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
@igrigorik 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
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

No commit comments for this range

Something went wrong with that request. Please try again.