Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add em.defer #133

Merged
merged 1 commit into from
Sep 5, 2012
Merged

add em.defer #133

merged 1 commit into from
Sep 5, 2012

Conversation

kostya
Copy link
Contributor

@kostya kostya commented Sep 3, 2012

for outside reactor calculations

@igrigorik
Copy link
Owner

Hmmm, handy! Are you using this in any production code? It makes sense, but something feels odd about this.. for one, the simple examples will work just fine, but things like thread/fiber local variables and their respective scopes can lead to some very confusing behaviors..

@kostya
Copy link
Contributor Author

kostya commented Sep 3, 2012

not using this in production, but using pure em.defer and its ok.
it seems would be ok.
little test, this behaviour with sinatra-sinchrony

  get '/sleep' do
    x = y = rand(1000)

    r = EM::Synchrony.defer{
      sleep 0.2
      x += 2
      2
    }

    return halt(500) if r != 2
    return halt(500) if x != y + 2

    "OK"
  end

ab -n 1000 -c 1000 not any 500.

Or you mean combinations defer + another synchrony calls?
But maybe would be some confusions with exceptions.

@igrigorik
Copy link
Owner

We already have a similar / confusing barrier with async iterators, where you need to launch a new fiber within the block. ex: EM::Synchrony.defer { EM::Synchrony.sleep(1) } would crash and burn.

Unfortunately, there is no simple solution for this..

igrigorik added a commit that referenced this pull request Sep 5, 2012
@igrigorik igrigorik merged commit 6f23d79 into igrigorik:master Sep 5, 2012
@kostya
Copy link
Contributor Author

kostya commented Sep 5, 2012

i consider that defer only for long synchronious operations like nokogiri parsing, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants