这个问题看起来类似于我的Scala actor的属性应该标记为@volatile吗?但不确定答案是否相同.
例如,如果配置了fork-join调度程序并且actor的状态没有被@volatile标记,那么是否保证actor的状态将通过缓存层次结构从一个核心(或处理器)传播到另一个核心(或处理器)/join工作线程在不同的核心(或处理器)上运行?
PS JSR133之后只有一个写入/读取操作到/从任何易失性变量执行刷新缓存到主内存并在其他核心(或处理器)上运行的其他线程上看到来自此线程的所有前面的非易失性写入,这是正确的吗?如果是,则可以回答,因为扫描工作队列会执行一些读数并从/向FJ任务的volatile变量写入.
为什么ForkJoinPool是为Scala分叉的?
哪种实施方式以及哪种情况更受青睐?
对于put和get运营OpenHashMap表现优于HashMap大约5倍:https://gist.github.com/1423303
是否HashMap应优先考虑何时OpenHashMap?
在最新的里程碑中找不到scala.actors包,虽然它仍然存在于scaladocs中:https://oss.sonatype.org/content/groups/public/org/scala-lang/scala-library/2.10.0-M6
斯卡拉
码:
@annotation.tailrec
private def fastLoop(n: Int, a: Long = 0, b: Long = 1): Long =
if (n > 1) fastLoop(n - 1, b, a + b) else b
Run Code Online (Sandbox Code Playgroud)
字节码:
private long fastLoop(int, long, long);
Code:
0: iload_1
1: iconst_1
2: if_icmple 21
5: iload_1
6: iconst_1
7: isub
8: lload 4
10: lload_2
11: lload 4
13: ladd
14: lstore 4
16: lstore_2
17: istore_1
18: goto 0
21: lload 4
23: lreturn
Run Code Online (Sandbox Code Playgroud)
结果是53879289.462 ± 6289454.961 ops/s …
我们在项目中使用 Lift + Mapper(版本 2.4)。我们也使用每个请求的事务模式S.addAround(DB.buildLoanWrapper())。
在我们的一个请求中,我们需要嵌套事务,我们发现这是有问题的。我们发现可能的“黑客”之一是在单独的线程中启动事务(如下例所示),因为DB对象用于ThreadLocal管理当前连接和事务状态信息。
是否有任何实现比下面的更好(更安全并且没有多线程)?
\n\n import net.liftweb.db.{DefaultConnectionIdentifier, DB}\n import akka.dispatch.Future\n\n /**\n * Will create a new transaction if none is in progress and commit it upon completion or rollback on exceptions.\n * If a transaction already exists, it has no effect, the block will execute in the context\n * of the existing transaction. The commit/rollback is handled in this case by the parent transaction block.\n */\n def inTransaction[T](f: \xe2\x87\x92 …Run Code Online (Sandbox Code Playgroud) 的JSON规范规定,必须转义控制字符仅与从U + 0000到U + 001F代码:
7. Strings
The representation of strings is similar to conventions used in the C
family of programming languages. A string begins and ends with
quotation marks. All Unicode characters may be placed within the
quotation marks, except for the characters that must be escaped:
quotation mark, reverse solidus, and the control characters (U+0000
through U+001F).
Run Code Online (Sandbox Code Playgroud)
转义的主要思想是在终端或纸张上打印 JSON 文档或消息时不损坏输出。
但是还有其他控制字符,例如来自 C0 的 [DEL] 和来自 C1 的其他控制字符集 (U+0080 到 U+009F)。他们不应该也在 JSON 字符串中转义吗?
100 万个 Akka 演员的实例在我的笔记本上花费了大约 20 秒:http : //goo.gl/OwQht
scala ×6
actor ×3
akka ×2
java ×2
escaping ×1
fork-join ×1
jmh ×1
json ×1
lift ×1
lift-mapper ×1
scala-2.10 ×1
string ×1
transactions ×1
volatile ×1