如果没有IO线程来处理异步结果,会发生什么情况?(What happens if there are no IO threads to handle async result?)
我想知道当没有IO线程处理异步调用的结果时会发生什么。
假设你做了一个异步web请求(在服务器应用程序中,所有异步代码都由线程池处理)。 操作系统会发出信号,告诉您何时有结果,何时需要IO线程来读取套接字中的字节。 如果没有IO线程可用,因为这些线程都在使用中(全部含义由线程池设置的最大值)会发生什么情况? 有信号可以等待,直到有线程可用的队列吗? 还是信号只是闻所未闻? 如果后者发生,等待等待的代码会发生什么?
I'm wondering what happens when there are no IO threads to handle the result of an async call.
Say you make an async web request (in a server application so all async code is handeled by the thread pool). The OS will signal when there is a result for you and when it does you'll need an IO thread to read the bytes from the socket. If there are no IO threads available because that are all in use (all meaning up to the max set by the thread pool) what happens? Is there a queue where the signal can wait until there is a thread available? Or does the signal just go unheard? If the latter happens, what happens to the code waiting on the await?
原文:https://stackoverflow.com/questions/39053762
最满意答案
你也需要转换第二个参数:它是一个int参数,但你的数字是长的。 显然编译器可以在某些情况下(例如这个)解决它,但是一旦你开始提供类型提示,你就应该完成消除歧义。
user> (Math/scalb (double 21) (int -63)) 2.2768245622195593E-18
You need to convert the second argument too: it's an int argument, but your numbers are longs. Obviously the compiler could figure it out in some cases (such as this one), but once you start providing typehints you're expected to finish disambiguating.
user> (Math/scalb (double 21) (int -63)) 2.2768245622195593E-18
相关问答
更多-
解决Clojure中重载的float / double方法变体(Resolving overloaded float/double method variants from Clojure)[2022-01-11]
你也需要转换第二个参数:它是一个int参数,但你的数字是长的。 显然编译器可以在某些情况下(例如这个)解决它,但是一旦你开始提供类型提示,你就应该完成消除歧义。 user> (Math/scalb (double 21) (int -63)) 2.2768245622195593E-18 You need to convert the second argument too: it's an int argument, but your numbers are longs. Obviously the c ... -
从关于Clojure讨论组的讨论中 ,您似乎遇到了Rich Hickey所做的设计决定。 具体来说,因为BigDecimal没有签名BigDecimal(Long long)的构造函数(编辑:因此编译器必须在int和long构造函数之间进行选择 - 请参阅下面有关为什么使用Integer工作的讨论的注释),编译器将不要试图“猜测”你的意思,并明确地失败。 底线是Java端的特定类型要求,为了有正确和非脆弱的代码,需要显式装箱。 - Rich Hickey 请注意,根据本文档 ,文字被解析为基元,而不是“盒装 ...
-
在Clojure中施放nil(Casting nil in Clojure)[2024-03-13]
cast不会做你认为它只是确保第二个参数是指定类并返回它(第二个参数,而不是类)或抛出异常。 您需要添加类型提示,但不能直接将其添加到nil : => (String. nil) CompilerException java.lang.IllegalArgumentException: More than one matching method found: java.lang.String 这里我有一个例外,因为nil匹配太多的重载并且编译器不知道要选择哪个。 => (let [^String cnil ... -
您的名称空间声明是错误的 (ns bulbs.neo4jserver.client (:use [bulbs.base.client :only [ClientProtocol]])) 协议功能是正常的Clojure功能,必须这样处理。 因此,您必须将它们包含在:only子句中。 (ns bulbs.neo4jserver.client (:use [bulbs.base.client :only [create-edge ClientProtocol]])) Your namespace de ...
-
在java中重载的方法(overloaded methods in java)[2022-03-23]
是的,它们是重载方法,因为它们具有相同的名称但参数类型不同。 apomeme的答案给出了更多细节。 回答第二个问题: 你的电话eJava(111, "word", 222)不是含糊不清的,也不是汇编错误。 它匹配第一个方法: eJava(int age, String name, double duration) 。 它不能匹配第二种方法,因为它的第三个参数是一个字节,并且int文本不能隐式转换为一个字节。 除非您明确施放它们,否则不允许这种缩小转换。 但是,如果第二种方法是 float eJava(dou ... -
你错过了一个参数。 reify实现的每个方法的第一个参数是对象本身(与defrecord / deftype )。 所以,试试这个: (defn -create-message-factory [] (reify quickfix.MessageFactory (create [this beginString msgType] nil) (create [this beginString msgType correspondingFieldID] nil) ...
-
有一种机制可以与gen-class并允许覆盖相同的arity重载方法。 除了前缀和方法名称之外,我们还可以定义包含参数类型的名称的变量/函数。 要覆盖像foo(String s, Object o)这样的方法foo(String s, Object o)我们可以定义一个名为-foo-String-Object的var。 代码将在回-foo之前查找因此命名的var。 至少在一个Clojure邮件列表线程中记录了这一点。 在实践中,这意味着您可以编写如下代码: (defn interop-compare [th ...
-
以下是一些基本的演示示例: (import 'javax.measure.unit.SI) (import 'javax.measure.Measure) ; Integer Value ; will call: ; public static
Measure
valueOf (Measure/valueOf (Integer. 2) SI/KILOGRAM) ; Long value ; will call: ... -
据我所知,这种可见性定义为:private var的meta :private标志。 所以这两个表达式是相同的: (defn ^:private foo [] "bar") (defn- foo [] "bar") 所以我认为你只能控制整个var的可见性。 我可以建议为公共和私人空间使用不同的函数名称。 即公共的func-name和私有的func-name- 。 As I know this visibility is defined by :private flag in var's meta. So ...
-
我刚用你的代码测试过。 getValue()实际上返回所选项目的索引(仅当您设置显示的值时)。 所有你需要做的就是解析字符串,你会得到你想要的。 String[] nums = {"1","1.5","2","2.5","3","3.5","4","4.5","5","5.5","6","6.5","7","7.5","8","8.5","9"}; int index = listeningScorenp.getValue(); String val = nums[index]; float selecte ...