Lines Matching refs:sptr
20 ### OHOS::sptr
30 class OHOS::sptr;
37 * **T** 被sptr管理的具体类型。该类必须继承自RefBase基类。
47 | | **sptr**() …
48 …sptr< T > | template <typename... Args><br>**MakeSptr**(Args&&... a…
49 | template <typename O \> <br> | **sptr**(const sptr< O >& other)<br>拷贝构造函数,参数与当前sptr具有不…
50 | | **sptr**(const sptr< T >& other)<br>拷贝构造函数。其以参数指定具体管理对象…
51 | | **sptr**(sptr< T >&& other)<br>移动构造函数 …
52 … | **sptr**(T* other)<br>构造函数。其以参数指定具体管理对象<br> **注意: 不建议使用对象指针的形式构造sptr…
53 | | **sptr**(WeakRefCount* p, bool force)<br>构造函数。仅用于wptr的p…
54 | | **~sptr**() …
55 | void | **clear**()<br>移除当前sptr与所管理对象的引用关系 …
57 | T* | **GetRefPtr**() const<br>获取sptr管理对象的指针 …
59 | | **operator bool**() const<br>布尔类型转换运算符。检查sptr对象是否为空对象 …
60 | bool | **operator!=**(const sptr< T >& other) const<br>sptr对象间…
61 | bool | **operator!=**(const T* other) const<br>sptr对象与裸指针间的不等运…
62 | bool | **operator!=**(const wptr< T >& other) const<br>sptr对象与…
64 | T* | **operator->**() const<br>成员选择运算符,其将会返回被sptr管理对象的指定成员 …
65 | template <typename O \> <br>sptr< T >& | **operator=**(const sptr< O >& other)<br>拷贝赋值运算符,参数为一个sp…
66 | sptr< T >& | **operator=**(const sptr< T >& other)<br>拷贝赋值运算符,参数与当前sp…
67 | sptr< T >& | **operator=**(const wptr< T >& other)<br>拷贝赋值运算符,参数为一个wp…
68 | sptr< T >& | **operator=**(sptr< T >&& other)<br>移动构造运算符 …
69 | sptr< T >& | **operator=**(T* other)<br>拷贝赋值运算符,参数为待管理的具体对象<br>**注意: …
70 | bool | **operator==**(const sptr< T >& other) const<br>sptr对象间…
71 | bool | **operator==**(const T* other) const<br>sptr对象与裸指针间的相等运…
72 | bool | **operator==**(constwptr< T >& other) const<br>sptr对象与w…
102 | template <typename O \> <br> | **wptr**(const sptr< O >& other)<br>拷贝构造函数。参数为一个sptr对象,…
103 | | **wptr**(const sptr< T >& other)<br>拷贝构造函数。参数为一个sptr对象,…
110 … | **operator!=**(const sptr< T >& other) const<br>wptr与输入sptr对象间…
115 …late <typename O \> <br>wptr< T >& | **operator=**(const sptr< O >& other)<br>拷贝赋值运算符,参数为一个sptr对象,…
116 …< T >& | **operator=**(const sptr< T >& other)<br>拷贝赋值运算符,参数为一个sptr对象,…
121 … | **operator==**(const sptr< T >& other) const<br>wptr与输入sptr对象间…
124 | const sptr< T > | **promote**() const<br>将该wptr提升为sptr …
168 sptr<RefBaseTest> newSptr(new RefBaseTest());
177 sptr<RefBaseTest> curSptr(newSptr);
186 sptr<SubRefBaseTest> subSptr(new SubRefBaseTest());
201 sptr<RefBaseTest> scurSptr(new RefBaseTest);
206 sptr<RefBaseTest> soldSptr(new RefBaseTest);
208 soldSptr = scurWptr; // sptr仅可通过拷贝赋值管理wptr所管理对象
215 // 8. wptr可升级为sptr
216 sptr<RefBaseTest> spromotedWptr = snewWptr.promote(); // 升级失败时返回空sptr对象,即未管理具体对象的sptr对象
274 (sptr pointer) start tracking
275 (sptr pointer) call (RefBase pointer). strong: x weak: x refcnnt: x
277 (sptr pointer) call (RefBase pointer). strong: x weak: x refcnnt: x
278 (sptr pointer) end tracking
281 (sptr pointer) start backtrace
282 (sptr pointer) call (RefBase pointer). strong: x weak: x refcnnt: x PID: xxx TID: xxx
284 (sptr pointer) call (RefBase pointer). strong: x weak: x refcnnt: x PID: xxx TID: xxx
285 (sptr pointer) end backtrace
296 sptr<RefBase> s = a;
298 sptr<RefBase> s(a); // 裸指针a容易被误delete,造成sptr功能失常
306 3. **智能指针不保证线程安全**,使用者需保证线程安全以避免同时对同一个sptr对象赋值等操作
316 * sptr引用计数为0释放对象,对象指针依旧在外被继续使用
320 sptr<Refbase> sp1 = a; // 不建议,对象指针a暴露在外,存在风险
321 sptr<Refbase> sp2(a); // 不建议,对象指针a暴露在外,存在风险
322 sptr<Refbase> sp3 = sptr<Refbase>::MakeSptr(arg1, arg2); // 建议,在内部构造Refbase对象,直接交与sptr管控使用
326 * 在未设置**ExtendObjectLifetime**的情况下,wptr不参与被管理对象的生命周期控制,对象生命周期由sptr的引用计数控制,但在极特殊情况下存在例外
329 // 由于历史设计原因,可以在sptr不存在的情况下,基于对象指针创建wptr对象。
330 // 在未设置ExtendObjectLifetime,且无sptr被创建的特殊少见情况下,为了防止内存泄漏,在wptr引用计数归0时会释放管理对象