Skip to content

Commit

Permalink
DRY up Backend::Base#start.
Browse files Browse the repository at this point in the history
Fix weird spec failure caused by magic matcher: has_error => be_error
  • Loading branch information
macournoyer committed Aug 1, 2008
1 parent d2ac3ad commit 528a99a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lib/thin/backends/base.rb
Expand Up @@ -45,16 +45,16 @@ def initialize
# Start the backend and connect it.
def start
@stopping = false
# Allow for early run up of eventmachine. TODO : maybe move this into
# a method or proc to DRY.
if EventMachine.reactor_running?
starter = proc do
connect
@running = true
end

# Allow for early run up of eventmachine.
if EventMachine.reactor_running?
starter.call
else
EventMachine.run do
connect
@running = true
end
EventMachine.run(&starter)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/request/parser_spec.rb
Expand Up @@ -169,7 +169,7 @@

sorta_safe.size.should == nread
parser.should be_finished
parser.should_not have_error
parser.should_not be_error
end
end

Expand Down

2 comments on commit 528a99a

@tmm1
Copy link
Collaborator

@tmm1 tmm1 commented on 528a99a Aug 1, 2008

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With EM 0.12.1 (released Real Soon Now), you can nest EM.run without having to check EM::reactor_running? explicitly.

@raggi
Copy link
Contributor

@raggi raggi commented on 528a99a Aug 1, 2008

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, there’s one remaining problem with that design though.

EM::run {} blocks the first time, and is async in future calls. This can have important semantic meaning.

Any which way, EM::run {} needs to be as high in the stack as possible. I’d love to see it moved to a loader in it’s entirety.

Please sign in to comment.