作者查詢 / developers

總覽項目: 發文 | 留言 | 暱稱
作者 developers 在 PTT [ C_and_CPP ] 看板的留言(推文), 共29則
限定看板:C_and_CPP
首頁
上一頁
1
下一頁
尾頁
[問題] shared_ptr 是否 atomic or thread safe
[ C_and_CPP ]16 留言, 推噓總分: +2
作者: lovejomi - 發表於 2019/07/12 03:06(6年前)
9Fdevelopers: 目前版本的shared_ptr和weak_ptr只有保證increment和07/14 11:42
10Fdevelopers: decrement ref count是atomic的,還有resource只會被07/14 11:43
11Fdevelopers: delete一次,但都不保證存取resource 是atomic。07/14 11:44
12Fdevelopers: C++20 有atomic_shared_ptr和atomic_weakk_ptr會解決07/14 11:45
13Fdevelopers: 這個問題07/14 11:45
14Fdevelopers: shared_ptr assignment threadsafe 的寫法 用c++17是07/14 12:04
15Fdevelopers: atomic_store(&ptr, localPtr)來代表 ptr = localPtr07/14 12:05
16Fdevelopers: 後者的結果是undefined behavior 因為有data race07/14 12:07
Re: [討論] 大家都怎麼學STL?
[ C_and_CPP ]32 留言, 推噓總分: +18
作者: loveme00835 - 發表於 2011/09/25 11:04(13年前)
15Fdevelopers:推C++ In-Depth Series,還有Meyers的Effective series09/26 09:57
[問題] Qt thread wait or sleep?
[ C_and_CPP ]9 留言, 推噓總分: +3
作者: tata111 - 發表於 2011/06/19 13:54(14年前)
2Fdevelopers:不知道qtthread的lib裡有沒有提供condition variable?06/21 10:07
3Fdevelopers:有的話,用一個do while loop,先用condition::wait()06/21 10:08
4Fdevelopers:來block current thread,當trigger來的時候,從06/21 10:09
5Fdevelopers:calling thread 去call condition::notify(),就可以06/21 10:10
6Fdevelopers:unblock你的working thread,然後執行你要做的事; 之後06/21 10:11
7Fdevelopers:再回到do while的開頭,然後condition::wait(),等下一06/21 10:12
8Fdevelopers:個trigger06/21 10:12
Re: [問題] template一問
[ C_and_CPP ]6 留言, 推噓總分: +1
作者: bignose1007 - 發表於 2011/06/18 13:45(14年前)
1Fdevelopers:這個問題似乎變成在不同的dll中去new和delete同一個06/19 00:23
2Fdevelopers:物件,應該是會有問題的。原本的例子只是想說明可以用06/19 00:25
3Fdevelopers:template specialization 或 traits,依據不同的type06/19 00:26
4Fdevelopers:來做選擇;在template function 裡用new並return一個06/19 00:27
5Fdevelopers:raw pointer的確不是一個好的design06/19 00:28
[問題] 請推薦Visual C++書籍
[ C_and_CPP ]16 留言, 推噓總分: +2
作者: GGGGGforever - 發表於 2011/04/14 10:52(14年前)
9Fdevelopers:c#: C# 4.0 The Complete Reference04/15 08:12
10Fdevelopers:c++ 中級:C++ Primer; 高級:Effective C++04/15 08:13
11Fdevelopers:More Effective C++, Effective STL04/15 08:14
12Fdevelopers:C# 的語言介面比較user friendly,不用去考慮複雜的記04/15 08:20
13Fdevelopers:憶體管理,也不用擔心memory leak,因為garbage04/15 08:21
14Fdevelopers:collector都幫你自動清除垃圾物件,也沒有pointer,04/15 08:22
15Fdevelopers:都是pass by reference,如此一來使用者可以省去很多時04/15 08:27
16Fdevelopers:間在語言本身,但其效能當然就比c++差一些04/15 08:30
首頁
上一頁
1
下一頁
尾頁