什么是"Jetty 6 Continuations"?以及它们与编程语言中的延续性相比如何? [英] What are "Jetty 6 Continuations" and how do they compare to the continuations found in programming languages?

查看:79
本文介绍了什么是"Jetty 6 Continuations"?以及它们与编程语言中的延续性相比如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个描述Web服务器与编程语言中的继续"机制的答案.

I'm looking for an answer that describes a "continuation" mechanism in a web server vs. a programming language.

我的理解是,使用延续,让"pi位数"生产者与"pi位数"消费者进行通信是很简单的,而无需显式线程化.

My understanding is that using continuations, it is trivial to have a "digits of pi" producer communicate with a "digits of pi" consumer, without explicit threading.

我听说过关于Jetty延续的很好的事情.我很好奇其他人的想法.

I've heard very good things about Jetty continuations. I am curious what others think.

我可能已经找到答案了,但无论如何我还是在问这个问题-作记录.

I may have already found my answer, but I'm asking the question here anyway - for the record.

推荐答案

它们与编程语言中的延续相比如何?

how do they compare to the continuations found in programming languages?

除了名称,它们没有其他共同之处.它只是通过提供Servlet一个用于存储和还原其状态的API来释放当前线程的机制,但是与真正的延续相反,它都是手动管理的,而真正的延续是从当前上下文自动推断出状态.

They have nothing in common apart from the name. It's merely a mechanism for freeing the current thread by giving Servlet an API for storing and restoring its state, but it's all rather manually managed as opposed to real continuations, where the state is automatically inferred from the current context.

在这种情况下的典型示例是分层(组合)Web服务,其中一个服务需要向其他服务发出许多请求,并且在发出这些请求时,将释放当前线程.请求完成后(可以在其他一些线程上异步完成),将调用servlet的resume方法,然后该方法将从请求结果中组合响应.

The prototypical example for cases where this makes sense is layered (composed) web services, where one service needs to make many requests to other services, and while these requests are made, the current thread is freed. Upon completions of the requests (which can be done asynchronously on some other threads), the servlet's resume method is called, which then will assemble the response from the results of the requests.

这篇关于什么是"Jetty 6 Continuations"?以及它们与编程语言中的延续性相比如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆