File tree Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change 2020
2121#define MAX_TIMES_NOT_SERVED 100
2222
23- #define MAX_NOT_EMPTY_TIMES 10
24-
2523using namespace gromox ;
2624
2725namespace {
@@ -258,27 +256,21 @@ void threads_pool_wakeup_all_threads()
258256 */
259257static void *tpol_scanwork (void *pparam)
260258{
261- int not_empty_times;
262-
263- not_empty_times = 0 ;
264259 while (!g_notify_stop) {
265- sleep (1 );
266260 if (contexts_pool_get_param (CUR_SCHEDULING_CONTEXTS) <= 1 ) {
267- not_empty_times = 0 ;
261+ sleep ( 1 ) ;
268262 continue ;
269263 }
270- not_empty_times++;
271- if (not_empty_times < MAX_NOT_EMPTY_TIMES)
264+ if (g_threads_pool_cur_thr_num >= g_threads_pool_max_num) {
265+ sleep ( 1 );
272266 continue ;
267+ }
273268 std::lock_guard tpd_hold (g_threads_pool_data_lock);
274- if (g_threads_pool_cur_thr_num >= g_threads_pool_max_num)
275- continue ;
276269 THR_DATA *pdata;
277270 try {
278271 pdata = new THR_DATA;
279272 } catch (const std::bad_alloc &) {
280273 mlog (LV_DEBUG, " E-2368: ENOMEM" );
281- not_empty_times = 0 ;
282274 continue ;
283275 }
284276 pdata->node .pdata = pdata;
@@ -288,14 +280,14 @@ static void *tpol_scanwork(void *pparam)
288280 if (ret != 0 ) {
289281 mlog (LV_WARN, " W-1445: failed to increase pool threads: %s" , strerror (ret));
290282 delete pdata;
291- not_empty_times = 0 ;
283+ sleep ( 1 ) ;
292284 continue ;
293285 }
294286 pthread_setname_np (pdata->id , " ep_pool/+" );
295287 double_list_append_as_tail (
296288 &g_threads_data_list, &pdata->node );
297289 g_threads_pool_cur_thr_num++;
298- not_empty_times = 0 ;
290+ usleep ( 500 ) ;
299291 }
300292 return nullptr ;
301293}
You can’t perform that action at this time.
0 commit comments