make threads sleep

This commit is contained in:
ZappoMan 2013-08-15 12:01:50 -07:00
parent 4f16157e51
commit 74100ad043
2 changed files with 8 additions and 0 deletions

View file

@ -29,6 +29,10 @@ void PacketSender::queuePacket(sockaddr& address, unsigned char* packetData, ssi
}
bool PacketSender::process() {
if (_packets.size() == 0) {
const uint64_t SEND_THREAD_SLEEP_INTERVAL = (1000 * 1000)/60; // check at 60fps
usleep(SEND_THREAD_SLEEP_INTERVAL);
}
while (_packets.size() > 0) {
NetworkPacket& packet = _packets.front();

View file

@ -18,6 +18,10 @@ void ReceivedPacketProcessor::queuePacket(sockaddr& address, unsigned char* pack
}
bool ReceivedPacketProcessor::process() {
if (_packets.size() == 0) {
const uint64_t RECEIVED_THREAD_SLEEP_INTERVAL = (1000 * 1000)/60; // check at 60fps
usleep(RECEIVED_THREAD_SLEEP_INTERVAL);
}
while (_packets.size() > 0) {
NetworkPacket& packet = _packets.front();
processPacket(packet.getAddress(), packet.getData(), packet.getLength());