RAII
Technology & Computing abbreviation · Programming
| Stands for | Resource acquisition is initialization |
|---|---|
| Categories | Technology & Computing |
RAII stands for Resource acquisition is initialization, a programming abbreviation.
A C++ idiom that ties a resource, such as memory, a file handle or a lock, to an object's lifetime, so the resource is released automatically in the destructor when the object goes out of scope. Smart pointers such as std::unique_ptr follow it.
Example: Wrap the mutex in a std::lock_guard; RAII guarantees it unlocks even if an exception is thrown.
Usage notes
Named by Bjarne Stroustrup, the creator of C++, and widely considered an awkward name for a simple idea; "scope-bound resource management" is a suggested alternative. Rust's ownership model builds the same principle into the language. Python's with statement and C#'s using statement are comparable constructs.
Related abbreviations
More programming abbreviations
- PR – Pull request
- PRNG – Pseudorandom number generator
- PTAL – Please take a look
- pwd – Print working directory
- PyPI – Python Package Index
- QA – Quality assurance (software)
- regex – Regular expression
- REPL – Read-eval-print loop
- REST – Representational state transfer
- RNG – Random number generator
- RoR – Ruby on Rails
- RPC – Remote procedure call