1- # The Perils Of Ownership Based Resource Management (OBRM)
1+ <!-- # The Perils Of Ownership Based Resource Management (OBRM) -->
2+ # 所有権に基づいたリソース管理(Ownership Based Resource Management, OBRM)の危険性について
23
4+ <!--
35OBRM (AKA RAII: Resource Acquisition Is Initialization) is something you'll
46interact with a lot in Rust. Especially if you use the standard library.
7+ -->
8+ OBRM(またの名をRAII: Resource Acquisition Is Initialization)とは、Rustにおいて
9+ 関連性の深い概念です。特に標準ライブラリと密接に関与します。
510
11+ <!--
612Roughly speaking the pattern is as follows: to acquire a resource, you create an
713object that manages it. To release the resource, you simply destroy the object,
814and 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
1218memory management. Which is the point, really: Rust is about control. However we
1319are not limited to just memory. Pretty much every other system resource like a
1420thread, 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