小编wil*_*nux的帖子

为什么clojure中的core.async的线程池是使用固定线程池的#核心次数加2加42创建的?

线程池实现在core.async Clojure的库使用尺寸=芯*2 + 42#的FixedThreadPoolExecutor.

(defonce the-executor
  (Executors/newFixedThreadPool
    (-> (Runtime/getRuntime)
        (.availableProcessors)
        (* 2)
        (+ 42))
    (conc/counted-thread-factory "async-dispatch-%d" true)))
Run Code Online (Sandbox Code Playgroud)

是否有理由使用这些数字(核心数乘以2加42)?这对所有设备都是最佳的吗?我只是想知道丰富的hickey(和贡献者)如何用这些数字来解决.


谢谢nullptr.

以下是对有兴趣的人的讨论:http://clojure-log.n01se.net/date/2013-08-29.html#15 : 45a

clojure core.async

6
推荐指数
1
解决办法
583
查看次数

如何使用Jsoup获取此文本?

如何使用Jsoup从以下html代码中获取"this text"?

<h2 class="link title"><a href="myhref.html">this text<img width=10 
        height=10 src="img.jpg" /><span class="blah">
        <span>Other texts</span><span class="sometime">00:00</span></span>
        </a></h2>
Run Code Online (Sandbox Code Playgroud)

当我尝试

String s = document.select("h2.title").select("a[href]").first().text();
Run Code Online (Sandbox Code Playgroud)

它返回

本文其他文本00:00

我试着在Jsoup中读取Selector的api 但是想不通多了.

另外我如何获得类的元素class="link title blah"(多个类?).原谅我,我只知道Jsoup和CSS.

java css-selectors html-parsing jsoup

5
推荐指数
1
解决办法
5281
查看次数

为什么clojure允许使用lessthan(<)或大于(>)运算符/函数的单个参数

为什么clojure允许使用lessthan(<)或大于(>)运算符/函数的单个参数?我想知道为什么它只是返回'true'而不是强迫至少2个参数?

资源:

(defn >
  "Returns non-nil if nums are in monotonically decreasing order,
  otherwise false."
  {:inline (fn [x y] `(. clojure.lang.Numbers (gt ~x ~y)))
   :inline-arities #{2}
   :added "1.0"}
  ([x] true)
  ([x y] (. clojure.lang.Numbers (gt x y)))
  ([x y & more]
   (if (> x y)
     (if (next more)
       (recur y (first more) (next more))
       (> y (first more)))
     false)))
Run Code Online (Sandbox Code Playgroud)

clojure

3
推荐指数
1
解决办法
880
查看次数

标签 统计

clojure ×2

core.async ×1

css-selectors ×1

html-parsing ×1

java ×1

jsoup ×1