~T() https://www.sonarsource.com/blog/beyond-the-rules-of-three-five-and-zero/
## +24
## Back To Basics Lifetime Management
## PHIL NASH
## 20 24 September 15 - 20 0 码力 |
66 页 |
8.43 MB
| 1 年前 3 ## +23
## Object Lifetime: From Start to Finish
## THAMARA ANDRADE
## 20 23 October 01 - 06
## Object Lifetime
## From Start to Finish
int main() {
if (doSomething(Foo().getBar())) {
// realizing I didn’t really understand the rules for object lifetime.
## What is object lifetime anyway?
### 6.8 Object lifetime
[basic.life]
The lifetime of an object or reference is a runtime property of the Initialization by a trivial copy/move constructor is non-vacuous initialization. — end note] The lifetime of an object of type T begins when:
(1.1) — storage with the proper alignment and size for type 0 码力 |
214 页 |
9.34 MB
| 1 年前 3 ## 20 23 October 01 - 06
## +23
## Lifetime Safety in C++: Past, Present and Future
#### GABOR HORVATH Gabor.Horvath@microsoft.com
## Welcome to CppCon 2023!
Come by our booth and join #visual_studio https://aka.ms/cppcon/lifetime
0

Approaches to safety
## ↑
C++ is getting safer
The lifetime safety toolbox
What nts/9/d/0/5/9d05b80becbd0a2aac297caf075ed3c2/p24_2.jpg)
• ASAN, GWP-ASAN, HWASAN + Fuzzing
• Lifetime Safety Profile, Crubit
• C26815, C26816
• Cyclone, P2771
-Wdangling-gsl
-Wdangling-reference 0 码力 |
124 页 |
2.03 MB
| 1 年前 3 optimization opportunities.
## Container Level Variables
Container level variables have static lifetime and are order-independent and lazily analyzed. The initialization value of container level variables tests passed.
## Static Local Variables
It is also possible to have local variables with static lifetime by using containers inside functions.
static local variable.zig
const std = @import("std"); will provide such protection, with some degree of cooperation from Zig code required.
## Lifetime and Ownership
It is the Zig programmer's responsibility to ensure that a pointer is not accessed when 0 码力 |
234 页 |
6.01 MB
| 2 年前 3 and talking about C++
makers.f.dev@gmail.com
## Outline
• Motivation
• Overview
• Patterns
• Lifetime
• Exceptions
• RAII
• Synchronization
## • Conclusions
## Motivation
• 40 years of
• Experience /8/e20839ae14710dcbb38ddda7e6a7f799/p14_1.jpg)
## Patterns
• Lifetime
• Exceptions
• RAII
• Synchronization
## Lifetime
## Lifetime
• Lots of worries
• Use Structured Concurrency $ ^{[1]} $
• https://ericniebler.com/2020/11/08/structured-concurrence/
## Lifetime
Member coroutines implicitly capture this
## Lifetime
Let's play a game
## Lifetime
struct Bar {
int data = 0;
Task mul_2(Task 0 码力 |
70 页 |
1.45 MB
| 1 年前 3 share/vehicle semantics across the set of source files making up a component
## Module Ownership
## Module Ownership
- Supporting programming in the large (componentization)
- Non-interference between between module-local entities (module linkage)
- Interface provenance:
- Weak ownership – good
- Strong ownership – better
- ODR guarantees
- An entity is owned by exactly one module
- Reachability - Allows implementation freedom to enforce ownership
- Throughout the entire toolchain, from parser to linker
- MSVC implements a 'strong ownership' model.
- Hope: More C++ toolsets offer 0 码力 |
53 页 |
1.33 MB
| 1 年前 3 breaking the potential ownership cycle
Service objects are owned by an ExecutionContext
ExecutionContext destroys all services (and therefore completion handlers) as its lifetime ends
struct my_service is established lifetime of Executor corresponds to lifetime of outstanding work against the underlying ExecutionContext
In case of std::net::io_context::run will not return until lifetime of all such Executor guarantees of Networking TS from scratch
Completion handlers must be stored in a Service to avoid ownership cycles
Outstanding work must be tracked to ensure underlying ExecutionContext still available upon 0 码力 |
35 页 |
900.82 KB
| 1 年前 3 }
}
}
}
);
Manual lifetime management
## 原生 原生 原生
// read length
auto len = make_unique();
async_read(socket .handle data...
## Coroutines may simplify things
• Easier reasoning
• Easier object lifetime management
• Easier error propagation
But we need some structure
## Structured concurrency
And of the program
## Detached tasks considered harmful
No way to figure out task lifetime
=> no automatic object lifetime management
// don't do this
void bad(tcp::socket& s) {
std::array 0 码力 |
103 页 |
1.98 MB
| 1 年前 3 in the right direction.”
• Agile tie-in: Scrum and the use of time boxes
## The High Price of Ownership – Why We Overvalue What We Have
- Example: Duke basketball tickets – students must camp out in transaction from the same perspective as we do.”
“Ownership is not limited to material things. It can also apply to points of view. Once we take ownership of an idea—whether its about politics or sports—what 0 码力 |
3 页 |
234.46 KB
| 1 年前 3 . .
65
3.5
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
66
4
Understanding Ownership
77
4.1
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
77
4.2
. . . . . . . . . as variables, data types, and functions, and
shows how to use them in Rust. Chapter 4 explores ownership, which
is a Rust feature that is most different from other languages. Chapter
5 discusses structs concept in Rust that
doesn’t commonly exist in other programming languages: ownership.
78
Chapter 4
Understanding
Ownership
Ownership is Rust’s most unique feature, and it enables Rust to make
memory safety 0 码力 |
617 页 |
1.54 MB
| 2 年前 3
|