@@ -115,31 +115,59 @@ impl ClientData {
115
115
116
116
pub fn receivers ( & self ) -> MutexGuard < ClientReceivers > {
117
117
trace ! ( "Locking receivers" ) ;
118
- self . receivers . lock ( ) . unwrap ( )
118
+ self . receivers
119
+ . lock ( )
120
+ . expect ( "Threads should not panic while holding lock." )
119
121
}
120
122
121
123
pub fn echo_tx ( & self ) -> Sender < Bytes > {
122
- self . senders . read ( ) . unwrap ( ) . echo_tx . clone ( )
124
+ self . senders
125
+ . read ( )
126
+ . expect ( "Threads should not panic while holding lock." )
127
+ . echo_tx
128
+ . clone ( )
123
129
}
124
130
125
131
pub fn job_created_tx ( & self ) -> Sender < JobCreated > {
126
- self . senders . read ( ) . unwrap ( ) . job_created_tx . clone ( )
132
+ self . senders
133
+ . read ( )
134
+ . expect ( "Threads should not panic while holding lock." )
135
+ . job_created_tx
136
+ . clone ( )
127
137
}
128
138
129
139
pub fn error_tx ( & self ) -> Sender < ( Bytes , Bytes ) > {
130
- self . senders . read ( ) . unwrap ( ) . error_tx . clone ( )
140
+ self . senders
141
+ . read ( )
142
+ . expect ( "Threads should not panic while holding lock." )
143
+ . error_tx
144
+ . clone ( )
131
145
}
132
146
133
147
pub fn status_res_tx ( & self ) -> Sender < JobStatus > {
134
- self . senders . read ( ) . unwrap ( ) . status_res_tx . clone ( )
148
+ self . senders
149
+ . read ( )
150
+ . expect ( "Threads should not panic while holding lock." )
151
+ . status_res_tx
152
+ . clone ( )
135
153
}
136
154
137
155
pub fn worker_job_tx ( & self ) -> Sender < WorkerJob > {
138
- self . senders . read ( ) . unwrap ( ) . worker_job_tx . clone ( )
156
+ self . senders
157
+ . read ( )
158
+ . expect ( "Threads should not panic while holding lock." )
159
+ . worker_job_tx
160
+ . clone ( )
139
161
}
140
162
141
163
pub fn get_sender_by_handle ( & self , handle : & ServerHandle ) -> Option < Sender < WorkUpdate > > {
142
- match self . senders . read ( ) . unwrap ( ) . senders_by_handle . get ( handle) {
164
+ match self
165
+ . senders
166
+ . read ( )
167
+ . expect ( "Threads should not panic while holding lock." )
168
+ . senders_by_handle
169
+ . get ( handle)
170
+ {
143
171
None => None ,
144
172
Some ( sender) => Some ( sender. clone ( ) ) ,
145
173
}
@@ -148,13 +176,19 @@ impl ClientData {
148
176
pub fn set_sender_by_handle ( & mut self , handle : ServerHandle , tx : Sender < WorkUpdate > ) {
149
177
self . senders
150
178
. write ( )
151
- . unwrap ( )
179
+ . expect ( "Threads should not panic while holding lock." )
152
180
. senders_by_handle
153
181
. insert ( handle, tx) ;
154
182
}
155
183
156
184
pub fn get_jobs_tx_by_func ( & self , func : & Vec < u8 > ) -> Option < Sender < WorkerJob > > {
157
- match self . senders . read ( ) . unwrap ( ) . jobs_tx_by_func . get ( func) {
185
+ match self
186
+ . senders
187
+ . read ( )
188
+ . expect ( "Threads should not panic while holding lock." )
189
+ . jobs_tx_by_func
190
+ . get ( func)
191
+ {
158
192
None => None ,
159
193
Some ( tx) => Some ( tx. clone ( ) ) ,
160
194
}
@@ -163,7 +197,7 @@ impl ClientData {
163
197
pub fn set_jobs_tx_by_func ( & mut self , func : Vec < u8 > , tx : Sender < WorkerJob > ) {
164
198
self . senders
165
199
. write ( )
166
- . unwrap ( )
200
+ . expect ( "Threads should not panic while holding lock." )
167
201
. jobs_tx_by_func
168
202
. insert ( func, tx) ;
169
203
}
0 commit comments