1
- # The Perils Of Ownership Based Resource Management (OBRM)
1
+ <!-- # The Perils Of Ownership Based Resource Management (OBRM) -->
2
+ # 所有権に基づいたリソース管理(Ownership Based Resource Management, OBRM)の危険性について
2
3
4
+ <!--
3
5
OBRM (AKA RAII: Resource Acquisition Is Initialization) is something you'll
4
6
interact with a lot in Rust. Especially if you use the standard library.
7
+ -->
8
+ OBRM(またの名をRAII: Resource Acquisition Is Initialization)とは、Rustにおいて
9
+ 関連性の深い概念です。特に標準ライブラリと密接に関与します。
5
10
11
+ <!--
6
12
Roughly speaking the pattern is as follows: to acquire a resource, you create an
7
13
object that manages it. To release the resource, you simply destroy the object,
8
14
and it cleans up the resource for you. The most common "resource" this pattern
@@ -12,3 +18,14 @@ particularly important in Rust because we have no pervasive GC to rely on for
12
18
memory management. Which is the point, really: Rust is about control. However we
13
19
are not limited to just memory. Pretty much every other system resource like a
14
20
thread, file, or socket is exposed through this kind of API.
21
+ -->
22
+ このパターンを簡単に説明すると次のようになります。「リソースを獲得するには
23
+ そのリソースを管理するオブジェクトを作成し、リソースを解放するにはその
24
+ オブジェクトを単に破棄すればリソースがクリーンアップされる。」
25
+ いうものです。このように管理される最も一般的な「リソース」は単なる** メモリ** です。
26
+ ` Box ` 、` Rc ` 、その他` std::collections ` の諸々全ては、メモリの管理を便利にするためのものです。
27
+ Rustの場合、メモリの管理において一貫したGCに頼るということができないので、これら
28
+ は特に重要になります。大事なことなので強調しましょう。この「管理」という考え方は
29
+ Rustの根幹です。それは何もメモリに限った話ではありません。スレッド、ファイル、
30
+ ソケットといったほぼ全てのリソースがこういった考え方に基づくAPIを通して扱うように
31
+ できています。
0 commit comments