Global Information Lookup Global Information

Resource acquisition is initialization information


Resource acquisition is initialization (RAII)[1] is a programming idiom[2] used in several object-oriented, statically typed programming languages to describe a particular language behavior. In RAII, holding a resource is a class invariant, and is tied to object lifetime. Resource allocation (or acquisition) is done during object creation (specifically initialization), by the constructor, while resource deallocation (release) is done during object destruction (specifically finalization), by the destructor. In other words, resource acquisition must succeed for initialization to succeed. Thus the resource is guaranteed to be held between when initialization finishes and finalization starts (holding the resources is a class invariant), and to be held only when the object is alive. Thus if there are no object leaks, there are no resource leaks.

RAII is associated most prominently with C++, where it originated, but also Ada,[3] Vala,[4] and Rust.[5] The technique was developed for exception-safe resource management in C++[6] during 1984–89, primarily by Bjarne Stroustrup and Andrew Koenig,[7] and the term itself was coined by Stroustrup.[8]

Other names for this idiom include Constructor Acquires, Destructor Releases (CADRe)[9] and one particular style of use is called Scope-based Resource Management (SBRM).[10] This latter term is for the special case of automatic variables. RAII ties resources to object lifetime, which may not coincide with entry and exit of a scope. (Notably variables allocated on the free store have lifetimes unrelated to any given scope.) However, using RAII for automatic variables (SBRM) is the most common use case.

  1. ^ Stroustrup, Bjarne (2017-09-30). "Why doesn't C++ provide a "finally" construct?". Retrieved 2019-03-09.
  2. ^ Sutter, Herb; Alexandrescu, Andrei (2005). C++ Coding Standards. C++ In-Depth Series. Addison-Wesley. p. 24. ISBN 978-0-321-11358-0.
  3. ^ "Gem #70: The Scope Locks Idiom". AdaCore. Retrieved 21 May 2021.
  4. ^ The Valadate Project. "Destruction". The Vala Tutorial version 0.30. Retrieved 21 May 2021.
  5. ^ "RAII - Rust By Example". doc.rust-lang.org. Retrieved 2020-11-22.
  6. ^ Stroustrup 1994, 16.5 Resource Management, pp. 388–89.
  7. ^ Stroustrup 1994, 16.1 Exception Handling: Introduction, pp. 383–84.
  8. ^ Stroustrup 1994, p. 389. I called this technique "resource acquisition is initialization."
  9. ^ Arthur Tchaikovsky (2012-11-06). "Change official RAII to CADRe". ISO C++ Standard - Future Proposals. Google Groups. Retrieved 2019-03-09.
  10. ^ Chou, Allen (2014-10-01). "Scope-Based Resource Management (RAII)". Retrieved 2019-03-09.

and 17 Related for: Resource acquisition is initialization information

Request time (Page generated in 0.8521 seconds.)

Resource acquisition is initialization

Last Update:

Resource acquisition is initialization (RAII) is a programming idiom used in several object-oriented, statically typed programming languages to describe...

Word Count : 1984

Manual memory management

Last Update:

correctness advantage, which is that it allows automatic resource management via the Resource Acquisition Is Initialization (RAII) paradigm. This arises...

Word Count : 1417

Finalizer

Last Update:

reference counting is used (decrement reference counts); to release resources, particularly in the resource acquisition is initialization (RAII) idiom; or...

Word Count : 4013

Cadre

Last Update:

Constructor Acquires Destructor Releases, alternate name for Resource Acquisition Is Initialization programming idiom The Cadre (newspaper) All pages with titles...

Word Count : 185

Object lifetime

Last Update:

resource management: this is called the Resource Acquisition Is Initialization (RAII) idiom: resources are acquired during initialization, and released during...

Word Count : 3558

RRIF

Last Update:

Improvement Financing (U.S.A.) Resource Release Is Finalization, an alternate name for the Resource Acquisition Is Initialization (RAII) programming idiom This...

Word Count : 64

Dispose pattern

Last Update:

during object destruction. This approach is known as the Resource Acquisition Is Initialization (RAII) idiom, and is used in languages with deterministic...

Word Count : 1988

Automatic variable

Last Update:

manage resource allocation and deallocation, like opening and then automatically closing files or freeing up memory. See Resource Acquisition Is Initialization...

Word Count : 767

Wrapper library

Last Update:

locked mutex. The new interface effectively utilizes RAII (Resource Acquisition is Initialization) in the new Mutex and Lock classes to ensure Mutexs are...

Word Count : 441

List of computing and IT abbreviations

Last Update:

Service RAID—Redundant Array of Independent Disks RAII—Resource Acquisition Is Initialization RAIT—Redundant Array of Inexpensive Tapes RAM—Random-Access...

Word Count : 6615

Dangling pointer

Last Update:

necessary initialization prior to first use. Thus, strictly speaking, every pointer in programming languages which do not enforce initialization begins as...

Word Count : 1781

Memory leak

Last Update:

of the programming errors that cause memory leaks. Resource acquisition is initialization (RAII) is an approach to the problem commonly taken in C++, D...

Word Count : 2718

Structured programming

Last Update:

exist to encapsulate resource management. An alternative approach, found primarily in C++, is Resource Acquisition Is Initialization, which uses normal...

Word Count : 3717

Software design pattern

Last Update:

of a computer program in terms of how to write the code. Using a pattern is intended to leverage an existing concept rather than re-inventing it. This...

Word Count : 2802

Smart pointer

Last Update:

science) Boost (C++ libraries) Automatic Reference Counting Resource acquisition is initialization (RAII) Garbage collection in computer programming Kline...

Word Count : 1847

History of Python

Last Update:

block of code is run and releasing the lock afterwards, or opening a file and then closing it), allowing resource acquisition is initialization (RAII)-like...

Word Count : 3514

RIIA

Last Update:

known as the Royal Institute of International Affairs; Resource initialization is acquisition, concept from computer science rIIA the A cistron of the...

Word Count : 71

PDF Search Engine © AllGlobal.net