Modify in process_queue(void* shard_num)
Moderator: Forum Moderators
Modify in process_queue(void* shard_num)
Code: Select all
if(min_threads && waiting_threads[shard] >= min_threads) {
DBG_NW << "worker thread exiting... not enough jobs\n";
to_clear[shard].push_back(threading::get_current_thread_id());
return 0;
}
Code: Select all
if(outgoing_bufs[shard].empty() && min_threads && waiting_threads[shard] >= min_threads) {
DBG_NW << "worker thread exiting... not enough jobs\n";
to_clear[shard].push_back(threading::get_current_thread_id());
return 0;
}
Why do it? when work in server mode, consider below command sequence. Assume min_threads = 2.
- Thread#1 detect outgoing_buf isn't empty, so set socket to SOCKET_LOCKED, and send data.
More data push into outgoing_buf, and Thread#2 is waken up, but socket is in SOCKET_LOCKED, go to bed continue.
More data push into outgoing_buf, and Thread#3 is waken up, but socket is in SOCKET_LOCKED, go to bed continue.
Thread#1 finish send, goto while entry and decide whether exit self. Satisfy "min_threads && waiting_threads[shard] >= min_threads", Thread#1 exit!
Thread#2 and Thred#3 are in bed, until other receive/send wake it up. But duration it, data in outgoing_buf is delay.
Re: Modify in process_queue(void* shard_num)
You might want to provide more context for your post and/or send us a patch or pull request. If there is a bug involved, either include a link to the bug report or file a new one. Also note that many of the C++ coders in the development team only occasionally use the forums and prefer IRC or the mailing list instead.
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.