Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

3.3.1代码3.11前的翻译建议 #59

Closed
zhourongtu opened this issue Jan 27, 2021 · 1 comment
Closed

3.3.1代码3.11前的翻译建议 #59

zhourongtu opened this issue Jan 27, 2021 · 1 comment

Comments

@zhourongtu
Copy link

image

3.3.1 代码3.11前
一段话

转为多线程代码时,只有①处需要保护,这样共享数据对于并发访问就是安全的。但是下面天真的转换会使得线程资源产生不必要的序列化,为了确定数据源已经初始化,每个线程必须等待互斥量。

原文

If the shared resource itself is safe for concurrent access, the only part that needs protecting when converting this to multithreaed code is initialization①, but a naive translation such as that in the following listing can cause unnecessary serialization of threads using the resource. This is because each thread must wait on the mutex in orther to check whether the resource has already been initialized.

建议改成

如果共享资源对于并发访问是安全的,那么唯一需要保护的地方就是①处(此处指上段代码中的①)。否则,按照3.11代码所示,所有的线程在进入foo()时会依次按顺序访问以避免同时访问,这显然是不必要的。这是因为每一个线程必须等待获取mutex才能确认资源是否被初始化。

原因
原文中的意思强调的是“当仅仅对共享资源需要初始化时,才需要提供锁避免重复初始化”。而这一大段一大段的介绍都是为了强调这一点,这些翻译让我觉得非常晦涩难懂,并且没有参照原文的逻辑顺序。
英文逻辑性是非常强的,同时,翻译时要尽可能完整,不偏离本身英文逻辑的含义,非常建议在翻译的时候,1.完整性,2.理解原文的含义。

@xiaoweiChen
Copy link
Owner

嗯,我不确定这样翻译是否合适,对于我而言看到你的这段翻译我会有疑惑。
具体的文字我就不去讨论了,#60已经给你说了原因。

要是继续选择我的译版进行阅读,建议fork一份,自行修改为适合自己阅读的方式。

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

No branches or pull requests

2 participants