Modify in process_queue(void* shard_num)

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
ancientcc
Posts: 24
Joined: April 16th, 2009, 10:07 am

Modify in process_queue(void* shard_num)

Post by ancientcc »

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;
}
modify to

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;
}
Add "outgoing_bufs[shard].empty()" to exit condition.

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.
User avatar
Iris
Site Administrator
Posts: 6798
Joined: November 14th, 2006, 5:54 pm
Location: Chile
Contact:

Re: Modify in process_queue(void* shard_num)

Post by Iris »

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.
Post Reply