Commit 18fcc5872344dd080b4f12cd32833cb634907e32
1 parent
ec07940a
adapt on separation of issue and emit of events
Showing
6 changed files
with
60 additions
and
44 deletions
... | ... | @@ -87,30 +87,33 @@ TR_commManagerPollSelect(void * _this, TR_Event event, int timeout) |
87 | 87 | TR_CommEndPoint endpoint = cmgr->endpoints[i]; |
88 | 88 | |
89 | 89 | if ((this->fds[i].revents & POLLIN) == POLLIN) { |
90 | + TR_Event event; | |
91 | + | |
90 | 92 | nevents--; |
91 | 93 | if (TR_INSTANCE_OF(TR_TcpSocket, endpoint->transport) |
92 | 94 | && ((TR_TcpSocket)endpoint->transport)->listen) { |
93 | - TR_eventHandlerIssueEvent( | |
94 | - (TR_EventHandler)this, | |
95 | + event = TR_eventSubjectEmit( | |
95 | 96 | (TR_EventSubject)endpoint, |
96 | 97 | TR_CET_EVENT_ACC_READY, |
97 | 98 | NULL); |
98 | 99 | } else { |
99 | - TR_eventHandlerIssueEvent( | |
100 | - (TR_EventHandler)this, | |
100 | + event = TR_eventSubjectEmit( | |
101 | 101 | (TR_EventSubject)endpoint, |
102 | 102 | TR_CEP_EVENT_READ_READY, |
103 | 103 | NULL); |
104 | 104 | } |
105 | + | |
106 | + TR_eventHandlerIssueEvent((TR_EventHandler)this, event); | |
105 | 107 | } |
106 | 108 | |
107 | 109 | if ((this->fds[i].revents & POLLOUT) == POLLOUT) { |
108 | 110 | nevents--; |
109 | 111 | TR_eventHandlerIssueEvent( |
110 | 112 | (TR_EventHandler)this, |
111 | - (TR_EventSubject)endpoint, | |
112 | - TR_CEP_EVENT_WRITE_READY, | |
113 | - NULL); | |
113 | + TR_eventSubjectEmit( | |
114 | + (TR_EventSubject)endpoint, | |
115 | + TR_CEP_EVENT_WRITE_READY, | |
116 | + NULL)); | |
114 | 117 | } |
115 | 118 | |
116 | 119 | if (nevents <= 0) break; | ... | ... |
... | ... | @@ -38,9 +38,10 @@ TR_commManagerShutdown(void * _this, TR_Event event) |
38 | 38 | if (this->endpoints[i]) { |
39 | 39 | TR_eventHandlerIssueEvent( |
40 | 40 | (TR_EventHandler)_this, |
41 | - (TR_EventSubject)this->endpoints[i], | |
42 | - TR_CEP_EVENT_CLOSE, | |
43 | - NULL); | |
41 | + TR_eventSubjectEmit( | |
42 | + (TR_EventSubject)this->endpoints[i], | |
43 | + TR_CEP_EVENT_CLOSE, | |
44 | + NULL)); | |
44 | 45 | } |
45 | 46 | } |
46 | 47 | ... | ... |
... | ... | @@ -67,9 +67,10 @@ connectorAccept(void * _this, TR_Event event) |
67 | 67 | 8192); |
68 | 68 | TR_eventHandlerIssueEvent( |
69 | 69 | (TR_EventHandler)this, |
70 | - (TR_EventSubject)new_con, | |
71 | - TR_CON_EVENT_NEW_CON, | |
72 | - NULL); | |
70 | + TR_eventSubjectEmit( | |
71 | + (TR_EventSubject)new_con, | |
72 | + TR_CON_EVENT_NEW_CON, | |
73 | + NULL)); | |
73 | 74 | socket = TR_socketAccept((TR_TcpSocket)connection->transport); |
74 | 75 | } |
75 | 76 | ... | ... |
... | ... | @@ -83,9 +83,10 @@ TR_commManagerDisableWrite(void * _this, TR_Event event) |
83 | 83 | if (TR_socketFinRd(endpoint->transport)) { |
84 | 84 | TR_eventHandlerIssueEvent( |
85 | 85 | this, |
86 | - event->subject, | |
87 | - TR_CEP_EVENT_SHUT_READ, | |
88 | - NULL); | |
86 | + TR_eventSubjectEmit( | |
87 | + event->subject, | |
88 | + TR_CEP_EVENT_SHUT_READ, | |
89 | + NULL)); | |
89 | 90 | } |
90 | 91 | |
91 | 92 | return 1; |
... | ... | @@ -113,16 +114,18 @@ TR_commManagerShutdownRead(void * _this, TR_Event event) |
113 | 114 | // close |
114 | 115 | TR_eventHandlerIssueEvent( |
115 | 116 | (TR_EventHandler)_this, |
116 | - event->subject, | |
117 | - TR_CEP_EVENT_CLOSE, | |
118 | - NULL); | |
117 | + TR_eventSubjectEmit( | |
118 | + event->subject, | |
119 | + TR_CEP_EVENT_CLOSE, | |
120 | + NULL)); | |
119 | 121 | } else if (TR_cepHasPendingData((TR_CommEndPoint)event->subject)) { |
120 | 122 | // handle pending data... close is issued from disableWrite |
121 | 123 | TR_eventHandlerIssueEvent( |
122 | 124 | (TR_EventHandler)_this, |
123 | - event->subject, | |
124 | - TR_CEP_EVENT_CLOSE, | |
125 | - NULL); | |
125 | + TR_eventSubjectEmit( | |
126 | + event->subject, | |
127 | + TR_CEP_EVENT_CLOSE, | |
128 | + NULL)); | |
126 | 129 | } else { |
127 | 130 | TR_cepSetClose((TR_CommEndPoint)event->subject); |
128 | 131 | } |
... | ... | @@ -138,9 +141,10 @@ TR_commManagerShutdownWrite(void * _this, TR_Event event) |
138 | 141 | if (TR_socketFinRd(((TR_CommEndPoint)event->subject)->transport)) { |
139 | 142 | TR_eventHandlerIssueEvent( |
140 | 143 | (TR_EventHandler)_this, |
141 | - event->subject, | |
142 | - TR_CEP_EVENT_CLOSE, | |
143 | - NULL); | |
144 | + TR_eventSubjectEmit( | |
145 | + event->subject, | |
146 | + TR_CEP_EVENT_CLOSE, | |
147 | + NULL)); | |
144 | 148 | } |
145 | 149 | |
146 | 150 | return 0; | ... | ... |
... | ... | @@ -54,25 +54,28 @@ ioHandlerRead(void * _this, TR_Event event) |
54 | 54 | case -1: |
55 | 55 | TR_eventHandlerIssueEvent( |
56 | 56 | (TR_EventHandler)_this, |
57 | - event->subject, | |
58 | - TR_CEP_EVENT_CLOSE, | |
59 | - NULL); | |
57 | + TR_eventSubjectEmit( | |
58 | + event->subject, | |
59 | + TR_CEP_EVENT_CLOSE, | |
60 | + NULL)); | |
60 | 61 | break; |
61 | 62 | |
62 | 63 | case -2: |
63 | 64 | TR_eventHandlerIssueEvent( |
64 | 65 | (TR_EventHandler)_this, |
65 | - event->subject, | |
66 | - TR_CEP_EVENT_SHUT_READ, | |
67 | - NULL); | |
66 | + TR_eventSubjectEmit( | |
67 | + event->subject, | |
68 | + TR_CEP_EVENT_SHUT_READ, | |
69 | + NULL)); | |
68 | 70 | break; |
69 | 71 | |
70 | 72 | case TRUE: |
71 | 73 | TR_eventHandlerIssueEvent( |
72 | 74 | (TR_EventHandler)_this, |
73 | - event->subject, | |
74 | - TR_CEP_EVENT_NEW_DATA, | |
75 | - NULL); | |
75 | + TR_eventSubjectEmit( | |
76 | + event->subject, | |
77 | + TR_CEP_EVENT_NEW_DATA, | |
78 | + NULL)); | |
76 | 79 | break; |
77 | 80 | } |
78 | 81 | |
... | ... | @@ -86,19 +89,21 @@ ioHandlerWrite(void * _this, TR_Event event) |
86 | 89 | TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; |
87 | 90 | |
88 | 91 | if (TR_cepWriteBuffered(endpoint)) { |
92 | + TR_Event event; | |
93 | + | |
89 | 94 | if (TR_cepHasPendingData(endpoint)) { |
90 | - TR_eventHandlerIssueEvent( | |
91 | - (TR_EventHandler)_this, | |
95 | + event = TR_eventSubjectEmit( | |
92 | 96 | event->subject, |
93 | 97 | TR_CEP_EVENT_PENDING_DATA, |
94 | 98 | NULL); |
95 | 99 | } else { |
96 | - TR_eventHandlerIssueEvent( | |
97 | - (TR_EventHandler)_this, | |
100 | + event = TR_eventSubjectEmit( | |
98 | 101 | event->subject, |
99 | 102 | TR_CEP_EVENT_END_DATA, |
100 | 103 | NULL); |
101 | 104 | } |
105 | + | |
106 | + TR_eventHandlerIssueEvent((TR_EventHandler)_this, event); | |
102 | 107 | } |
103 | 108 | |
104 | 109 | return TRUE; | ... | ... |
... | ... | @@ -56,9 +56,10 @@ protocolHandlerParse(void * _this, TR_Event event) |
56 | 56 | if (message) { |
57 | 57 | TR_eventHandlerIssueEvent( |
58 | 58 | (TR_EventHandler)_this, |
59 | - event->subject, | |
60 | - TR_CEP_EVENT_NEW_MSG, | |
61 | - message); | |
59 | + TR_eventSubjectEmit( | |
60 | + event->subject, | |
61 | + TR_CEP_EVENT_NEW_MSG, | |
62 | + message)); | |
62 | 63 | |
63 | 64 | if (message->close) { |
64 | 65 | // also check that we are a response. Well this is how it is done |
... | ... | @@ -86,9 +87,10 @@ protocolHandlerCompose(void * _this, TR_Event event) |
86 | 87 | if (TR_cepCompose(endpoint, message)) { |
87 | 88 | TR_eventHandlerIssueEvent( |
88 | 89 | (TR_EventHandler)_this, |
89 | - event->subject, | |
90 | - TR_CEP_EVENT_WRITE_READY, | |
91 | - NULL); | |
90 | + TR_eventSubjectEmit( | |
91 | + event->subject, | |
92 | + TR_CEP_EVENT_WRITE_READY, | |
93 | + NULL)); | |
92 | 94 | TR_delete(message); |
93 | 95 | } |
94 | 96 | ... | ... |
Please
register
or
login
to post a comment