-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ja: Translate Chapter 60 (Shared State) #1636
Closed
+52
−6
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14084,19 +14084,27 @@ msgid "" | |
"Rust uses the type system to enforce synchronization of shared data. This is " | ||
"primarily done via two types:" | ||
msgstr "" | ||
"Rustは共有されたデータの同期を強制するために型システムを利用します。これは主" | ||
"に2つの型により行われます:" | ||
|
||
#: src/concurrency/shared_state.md:6 | ||
msgid "" | ||
"[`Arc<T>`](https://doc.rust-lang.org/std/sync/struct.Arc.html), atomic " | ||
"reference counted `T`: handles sharing between threads and takes care to " | ||
"deallocate `T` when the last reference is dropped," | ||
msgstr "" | ||
"[`Arc<T>`](https://doc.rust-lang.org/std/sync/struct.Arc.html), アトミックに" | ||
"参照カウントする型 (atomic reference counted)を `T` とするとき : スレッド間" | ||
"の共有を扱い、最後の参照がドロップされたとき `T` をデアロケートすることを担当" | ||
"する、" | ||
|
||
#: src/concurrency/shared_state.md:8 | ||
msgid "" | ||
"[`Mutex<T>`](https://doc.rust-lang.org/std/sync/struct.Mutex.html): ensures " | ||
"mutually exclusive access to the `T` value." | ||
msgstr "" | ||
"[`Mutex<T>`](https://doc.rust-lang.org/std/sync/struct.Mutex.html): `T`の値へ" | ||
"の相互排他的なアクセスを確実にする。" | ||
|
||
#: src/concurrency/shared_state/arc.md:1 | ||
msgid "`Arc`" | ||
|
@@ -14107,6 +14115,8 @@ msgid "" | |
"[`Arc<T>`](https://doc.rust-lang.org/std/sync/struct.Arc.html) allows shared " | ||
"read-only access via `Arc::clone`:" | ||
msgstr "" | ||
"[`Arc<T>`](https://doc.rust-lang.org/std/sync/struct.Arc.html) は読み取り専用" | ||
"の共有アクセスを`Arc::clone`により可能にします:" | ||
|
||
#: src/concurrency/shared_state/arc.md:16 | ||
msgid "\"{thread_id:?}: {v:?}\"" | ||
|
@@ -14123,28 +14133,37 @@ msgid "" | |
"`Arc` stands for \"Atomic Reference Counted\", a thread safe version of `Rc` " | ||
"that uses atomic operations." | ||
msgstr "" | ||
"`Arc` は\"Atomic Reference Counted\"の略で、アトミック操作を利用するという点" | ||
"で、`Rc`がスレッド安全になったバージョンのようなものです。" | ||
|
||
#: src/concurrency/shared_state/arc.md:31 | ||
msgid "" | ||
"`Arc<T>` implements `Clone` whether or not `T` does. It implements `Send` " | ||
"and `Sync` if and only if `T` implements them both." | ||
msgstr "" | ||
"`Arc<T>` は `Clone` を実装します。これは`T`が`Clone`を実装するしないに関わり" | ||
"ません。`T`が`Send`と`Sync`の両方を実装している場合で、かつその場合に限り、" | ||
"`Arc<T>` は両者を実装します。" | ||
|
||
#: src/concurrency/shared_state/arc.md:33 | ||
msgid "" | ||
"`Arc::clone()` has the cost of atomic operations that get executed, but " | ||
"after that the use of the `T` is free." | ||
msgstr "" | ||
"`Arc::clone()`には実行されるアトミック操作のコストがあります。ただ、そのよう" | ||
"なアトミック操作の後は、`T`の利用は自由になります。" | ||
|
||
#: src/concurrency/shared_state/arc.md:35 | ||
msgid "" | ||
"Beware of reference cycles, `Arc` does not use a garbage collector to detect " | ||
"them." | ||
msgstr "" | ||
"参照サイクルに気をつけてください。`Arc` には参照サイクルを検知するためのガ" | ||
"ベージコレクタはありません。" | ||
|
||
#: src/concurrency/shared_state/arc.md:36 | ||
msgid "`std::sync::Weak` can help." | ||
msgstr "" | ||
msgstr "`std::sync::Weak` が役立ちます。" | ||
|
||
#: src/concurrency/shared_state/mutex.md:1 | ||
msgid "`Mutex`" | ||
|
@@ -14156,6 +14175,9 @@ msgid "" | |
"mutual exclusion _and_ allows mutable access to `T` behind a read-only " | ||
"interface:" | ||
msgstr "" | ||
"[`Mutex<T>`](https://doc.rust-lang.org/std/sync/struct.Mutex.html) は相互排他" | ||
"を確実にし、 _かつ_ 読み取り専用のインターフェースの裏側で `T` へのミュータブ" | ||
"ルなアクセスを可能にします:" | ||
|
||
#: src/concurrency/shared_state/mutex.md:11 | ||
#: src/concurrency/shared_state/mutex.md:18 | ||
|
@@ -14168,38 +14190,49 @@ msgid "" | |
"lang.org/std/sync/struct.Mutex.html#impl-Sync-for-Mutex%3CT%3E) blanket " | ||
"implementation." | ||
msgstr "" | ||
"[`impl<T: Send> Sync for Mutex<T>`](https://doc.rust-lang.org/std/sync/" | ||
"struct.Mutex.html#impl-Sync-for-Mutex%3CT%3E) のブランケット実装があることに" | ||
"注目してください。" | ||
|
||
#: src/concurrency/shared_state/mutex.md:31 | ||
msgid "" | ||
"`Mutex` in Rust looks like a collection with just one element - the " | ||
"protected data." | ||
msgstr "" | ||
"Rustにおける`Mutex`とは、一つの要素 — 保護されたデータ — からなるコレクション" | ||
"のようなものです。" | ||
kantasv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#: src/concurrency/shared_state/mutex.md:32 | ||
msgid "" | ||
"It is not possible to forget to acquire the mutex before accessing the " | ||
"protected data." | ||
msgstr "" | ||
"保護されたデータにアクセスする前に、相互排他を確保し忘れることはありません。" | ||
|
||
#: src/concurrency/shared_state/mutex.md:33 | ||
msgid "" | ||
"You can get an `&mut T` from an `&Mutex<T>` by taking the lock. The " | ||
"`MutexGuard` ensures that the `&mut T` doesn't outlive the lock being held." | ||
msgstr "" | ||
"`&Mutex<T>` からロックを取得することで、`&mut T`を得ることができます。この" | ||
"`MutexGuard`は`&mut T`が保持されているロックよりも長く存続しないことを保証し" | ||
"ます。" | ||
|
||
#: src/concurrency/shared_state/mutex.md:35 | ||
msgid "" | ||
"`Mutex<T>` implements both `Send` and `Sync` iff (if and only if) `T` " | ||
"implements `Send`." | ||
msgstr "" | ||
"`T`が`Send`を実装している場合で、かつその場合に限り、`Mutex<T>` は`Send`と" | ||
"`Sync`の両方を実装します。" | ||
|
||
#: src/concurrency/shared_state/mutex.md:36 | ||
msgid "A read-write lock counterpart - `RwLock`." | ||
msgstr "" | ||
msgstr "読み書きのロックの場合に対応するものがあります — `RwLock`。" | ||
|
||
#: src/concurrency/shared_state/mutex.md:37 | ||
msgid "Why does `lock()` return a `Result`? " | ||
msgstr "" | ||
msgstr "なぜ`lock()`は`Result`を返すのでしょう? " | ||
|
||
#: src/concurrency/shared_state/mutex.md:38 | ||
msgid "" | ||
|
@@ -14209,46 +14242,59 @@ msgid "" | |
"[`PoisonError`](https://doc.rust-lang.org/std/sync/struct.PoisonError.html). " | ||
"You can call `into_inner()` on the error to recover the data regardless." | ||
msgstr "" | ||
"スレッドにパニックを起こした`Mutex`がある場合、保護すべきデータが整合性の欠け" | ||
"た状態にある可能性を伝えるため、`Mutex`は「ポイゾンされた」(\"poisoned\")状" | ||
Comment on lines
+14245
to
+14246
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Referred to JA Rustbook's translation, i.e., "poison" -> "ポイゾン" https://doc.rust-jp.rs/rust-nomicon-ja/poisoning.html |
||
"態になります。ポイゾンされたMutexに対して `lock()` をコールすると、" | ||
"[`PoisonError`](https://doc.rust-lang.org/std/sync/struct.PoisonError.html)と" | ||
"ともに失敗します。`into_inner()` を用いることで、そのエラーにおいて、とりあえ" | ||
"ずデータを回復することはできます。" | ||
|
||
#: src/concurrency/shared_state/example.md:3 | ||
msgid "Let us see `Arc` and `Mutex` in action:" | ||
msgstr "" | ||
msgstr "`Arc` と `Mutex` の動作を見てみましょう:" | ||
|
||
#: src/concurrency/shared_state/example.md:6 | ||
msgid "// use std::sync::{Arc, Mutex};\n" | ||
msgstr "" | ||
|
||
#: src/concurrency/shared_state/example.md:23 | ||
msgid "Possible solution:" | ||
msgstr "" | ||
msgstr "考えられる解決策:" | ||
|
||
#: src/concurrency/shared_state/example.md:49 | ||
msgid "Notable parts:" | ||
msgstr "" | ||
msgstr "注目に値する箇所:" | ||
|
||
#: src/concurrency/shared_state/example.md:51 | ||
msgid "" | ||
"`v` is wrapped in both `Arc` and `Mutex`, because their concerns are " | ||
"orthogonal." | ||
msgstr "" | ||
"`v`は `Arc` と `Mutex`の両方でラップされています。なぜなら、それらの関心は互" | ||
"いに独立なものであるからです。" | ||
|
||
#: src/concurrency/shared_state/example.md:52 | ||
msgid "" | ||
"Wrapping a `Mutex` in an `Arc` is a common pattern to share mutable state " | ||
"between threads." | ||
msgstr "" | ||
"`Mutex`を`Arc`でラップすることは、スレッド間でミュータブルな状態を共有するた" | ||
"めによく見られるパターンです。" | ||
|
||
#: src/concurrency/shared_state/example.md:53 | ||
msgid "" | ||
"`v: Arc<_>` needs to be cloned as `v2` before it can be moved into another " | ||
"thread. Note `move` was added to the lambda signature." | ||
msgstr "" | ||
"`v: Arc<_>`は別のスレッドにムーブされる前に、`v2`としてクローンされる必要があ" | ||
"ります。`move` がラムダ式に追加されたことに注意してください。" | ||
|
||
#: src/concurrency/shared_state/example.md:54 | ||
msgid "" | ||
"Blocks are introduced to narrow the scope of the `LockGuard` as much as " | ||
"possible." | ||
msgstr "" | ||
"ブロック文は`LockGuard`のスコープを可能な限り狭めるために導入されています。" | ||
|
||
#: src/exercises/concurrency/morning.md:3 | ||
msgid "Let us practice our new concurrency skills with" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translation confidence: Low, Re: "atomic reference counted"