Skip to content
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

[Concurrency] typoの修正 #326

Merged
merged 1 commit into from
Jul 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions language-guide/concurrency.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ print(await logger.max)

この例では、`logger.max` へのアクセスは中断する可能性があります。アクターはその可変状態にアクセスすることを一度に 1 つのタスクのみに制限しているため、別のタスクからのコードが既にロガーとやり取りしている場合、このコードはプロパティへのアクセスを待機します。

対照的に、アクター内のコードはアクターのプロパティにアクセスするときに、`await` を記載しません。例えば、下記は `TemperatureLogsger` を新しい温度で更新するメソッドです:
対照的に、アクター内のコードはアクターのプロパティにアクセスするときに、`await` を記載しません。例えば、下記は `TemperatureLogger` を新しい温度で更新するメソッドです:

```swift
extension TemperatureLogger {
Expand Down Expand Up @@ -242,7 +242,7 @@ print(logger.max) // エラー

ある同時実行ドメインから別のドメインに共有できる型は、「`Sendable` 型\(_Sendable Types_\)」と呼ばれます。例えば、アクターメソッドを呼び出すときに引数として渡すことも、タスクの結果として返すこともできます。この章の前半の例では、同時実行ドメイン間で渡されるデータに対して常に安全に共有できる単純な値型を使用しているため、`Sendable` かどうか\(_sendability_\)については説明していません。一方で、一部の型は同時実行ドメイン間で安全に渡すことができません。例えば、可変プロパティを含み、それらのプロパティへのアクセスを直列化していないクラスは、異なるタスク間でそのクラスのインスタンスを渡すときに、予測できない誤った結果を生成する可能性があります。

`Sendable` プロトコルへの準拠を宣言することにより、型を `Sendable` なことを示すことができます。`Sendable` プロトコルにはコード要件はありませんが、Swift が強制するセマンティック要件があります。一般に、型を `Sendable` にするには 3 つの方法があります。
`Sendable` プロトコルへの準拠を宣言することにより、型が `Sendable` なことを示すことができます。`Sendable` プロトコルにはコード要件はありませんが、Swift が強制するセマンティック要件があります。一般に、型を `Sendable` にするには 3 つの方法があります。
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本当は 型が Sendable であることを示すことができます にしたいがlintで弾かれる。

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

おそらく「です、ます調ルール」のやつですね。必要であれば別issueで検討しましょう。


- 値型で、その内部の可変状態が全て他の `Sendable` なデータで構成されている場合。例えば、`Sendable` な格納プロパティを持つ構造体や、`Sendable` な関連値を持つ列挙型など
- 可変状態がなく、不変で `Sendable` なデータのみで構成されている場合。例えば、計算プロパティのみを持つ構造体やクラスなど
Expand Down