亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
1234
最近訪問板塊 發(fā)新帖
樓主: TiGEr.zZ
打印 上一主題 下一主題

[C] 在ANSI C下設計和實現(xiàn)簡便通用的signal-slot機制 [復制鏈接]

論壇徽章:
0
31 [報告]
發(fā)表于 2010-02-23 15:28 |只看該作者
作一些改進:

對assert附加了錯誤信息輸出,有助于使用;
更好的Arm C編譯器支持,包括RVDS和ADS,在RVDS下如果要編譯成thumb代碼模式的話,請在SIGNAL_CONNECT局部使用ARM模式,或者定義SLOT_USE_LONGJMP為1。

下載地址:
http://code.google.com/p/c-sigslot/downloads/list

論壇徽章:
0
32 [報告]
發(fā)表于 2010-02-23 19:31 |只看該作者
QT 用的就是這種機制。。。

論壇徽章:
0
33 [報告]
發(fā)表于 2010-02-25 22:24 |只看該作者
太長了,沒完全看。請問可以把它做成一個組件嗎?
本來想分析下Qt的信號槽機制,但一直沒有擠出時間

論壇徽章:
2
天秤座
日期:2013-08-20 16:44:51獅子座
日期:2014-04-09 17:53:48
34 [報告]
發(fā)表于 2013-08-09 14:16 |只看該作者
這是一個很有深度 廣度的帖子,得洗洗咀嚼.慢慢消化.

論壇徽章:
0
35 [報告]
發(fā)表于 2013-08-09 18:21 |只看該作者
寫的篇幅有些長,看起來會頭暈,真知灼見來自于對具體問題的揣摩,不一定要一一看完。

(1)掌握設計的準則,靈活性第一,增加靈活性可以通過提升抽象層次,延遲問題解決得到實現(xiàn)。
(2)難以直接解決的問題,可以通過引入附加的層次進行轉(zhuǎn)換解決。

目前從語言層面上,一個最直接提升抽象層次的方法就是Closure,Coroutine,Continuation,Lambda Expression等等,文章里面的核心是實際上是C中一個實現(xiàn)方法,但具體實現(xiàn)還不夠完善,包括最新更新到googlecode上的代碼,其實在寫這個代碼之前,也有其他人有過類似的想法,但似乎也都不夠完善。最終這種形式應該被并入到語言中,類似于函數(shù)式那樣,使用堆來動態(tài)維護回調(diào)的代碼及局部變量(運行環(huán)境)(文中的實現(xiàn)使用的是棧復制/構(gòu)建/渲染方法,而c++ lambda的實現(xiàn),不支持動態(tài)變量管理,需要維護引用變量的生命周期,我認為便利性上沒有充分滿足需求)。

很多人都把這種提升抽象層次的方法認為是實現(xiàn)異步的手段,甚至把兩者直接等同以來,后者實際上是縮小的應用范圍。反過來說signal-slot本身的終結(jié)目標應該是能夠適應異步事件的處理,這樣才可能發(fā)揮出其真正的威力,從操作系統(tǒng)到應用軟件,從計算機到現(xiàn)實世界,我們時時刻刻都在處理著各種各樣的異步并發(fā)事件。

所以googlecode上的項目將會更新到一個通用的更加完善異步signal-slot的基礎設施上來,同時提供一個通用的異步調(diào)用的方式,保證以任意形式并行的事件可以以高層次一致性需求得到處理,而這種并行性的基礎設施構(gòu)建與一個通用的無鎖優(yōu)先隊列上,從而完全從下而上的滿足了并行世界的本質(zhì)要求。

注:無鎖并行化需要的最小原語是CAS,Compare and Swap,這已經(jīng)并證明是充分的。

論壇徽章:
2
天秤座
日期:2013-08-20 16:44:51獅子座
日期:2014-04-09 17:53:48
36 [報告]
發(fā)表于 2013-08-12 11:34 |只看該作者
[root@localhost c-sigslot]# ls
c-sigslot  c-sigslot.pro  Makefile  sigslot  sigslot.c  sigslot.h  sigslot.o  test.c  test.o
[root@localhost c-sigslot]# ./c-sigslot
[SIGSLOT DEBUG] Warning: using a signal connection without fetching args at: file "test.c", line 61
[SIGSLOT DEBUG] Warning: using a signal connection without fetching args at: file "test.c", line 75
[SIGSLOT DEBUG] Warning: using a signal connection without fetching args at: file "test.c", line 88
[SIGSLOT DEBUG] Warning: using a signal connection without fetching args at: file "test.c", line 101
[SIGSLOT DEBUG] Warning: using a signal connection without fetching args at: file "test.c", line 113
signal: 1, 2
dynamic slot: int=-1, float=-20.000000
[SIGSLOT DEBUG] These variables modification commited to the fetching args: "j". at: file "test.c", line 38
slot 1: int=10, float=20.000000
[SIGSLOT DEBUG] Warning: without fetching args, the modification of local variables inside slot will not commit: file "test.c", line 61
slot 2: int=100, float=200.000000
slot 3: int=1000, float=2000.000000
slot 3 disconnected.
slot 5: int=100000, float=200000.000000

signal: 1, 2
dynamic slot: int=-1, float=-200.000000
[SIGSLOT DEBUG] These variables modification commited to the fetching args: "j". at: file "test.c", line 38
slot 1: int=10, float=20.000000
[SIGSLOT DEBUG] Warning: without fetching args, the modification of local variables inside slot will not commit: file "test.c", line 61
slot 2: int=100, float=200.000000
slot 5: int=100000, float=200000.000000
slot 5 disconnected.

signal: 1, 2
dynamic slot: int=-1, float=-2000.000000
[SIGSLOT DEBUG] These variables modification commited to the fetching args: "j". at: file "test.c", line 38
slot 1: int=10, float=20.000000
[SIGSLOT DEBUG] Warning: without fetching args, the modification of local variables inside slot will not commit: file "test.c", line 61
slot 2: int=100, float=200.000000

signal free
dynamic slot disconnected!
slot 1 disconnected.
slot 2 disconnected.
slot 4 disconnected.
[root@localhost c-sigslot]#

論壇徽章:
2
天秤座
日期:2013-08-20 16:44:51獅子座
日期:2014-04-09 17:53:48
37 [報告]
發(fā)表于 2013-08-12 14:00 |只看該作者
[root@localhost c-sigslot]# ./c-sigslot
signal: 1, 2
dynamic slot: int=-1, float=-20.000000
slot 1: int=10, float=20.000000
slot 2: int=100, float=200.000000
slot 3: int=1000, float=2000.000000
slot 3 disconnected.
slot 5: int=100000, float=200000.000000

signal: 1, 2
dynamic slot: int=-1, float=-200.000000
slot 1: int=10, float=20.000000
slot 2: int=100, float=200.000000
slot 5: int=100000, float=200000.000000
slot 5 disconnected.

signal: 1, 2
dynamic slot: int=-1, float=-2000.000000
slot 1: int=10, float=20.000000
slot 2: int=100, float=200.000000

signal free
dynamic slot disconnected!
slot 1 disconnected.
slot 2 disconnected.
slot 4 disconnected.
[root@localhost c-sigslot]#

論壇徽章:
10
戌狗
日期:2013-10-17 09:43:0215-16賽季CBA聯(lián)賽之廣東
日期:2018-02-05 11:22:1215-16賽季CBA聯(lián)賽之八一
日期:2016-07-04 12:26:1815-16賽季CBA聯(lián)賽之青島
日期:2016-06-08 11:15:4115-16賽季CBA聯(lián)賽之遼寧
日期:2016-04-05 10:10:1415-16賽季CBA聯(lián)賽之遼寧
日期:2016-03-11 11:11:48酉雞
日期:2014-12-18 14:35:48獅子座
日期:2014-02-20 10:14:07寅虎
日期:2013-12-02 13:48:2915-16賽季CBA聯(lián)賽之廣夏
日期:2018-03-21 08:51:10
38 [報告]
發(fā)表于 2013-08-22 15:51 |只看該作者
Mark.

論壇徽章:
0
39 [報告]
發(fā)表于 2019-01-16 15:02 |只看該作者
為什么不直接用函數(shù)指針,用setjmp/longjmp  搞這么復雜?

論壇徽章:
0
40 [報告]
發(fā)表于 2019-01-25 19:56 |只看該作者
收藏,可以手動實現(xiàn)一個。
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP