mirror of
https://github.com/overte-org/overte.git
synced 2025-08-13 01:16:06 +02:00
make threads sleep
This commit is contained in:
parent
4f16157e51
commit
74100ad043
2 changed files with 8 additions and 0 deletions
|
@ -29,6 +29,10 @@ void PacketSender::queuePacket(sockaddr& address, unsigned char* packetData, ssi
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PacketSender::process() {
|
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) {
|
while (_packets.size() > 0) {
|
||||||
NetworkPacket& packet = _packets.front();
|
NetworkPacket& packet = _packets.front();
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,10 @@ void ReceivedPacketProcessor::queuePacket(sockaddr& address, unsigned char* pack
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReceivedPacketProcessor::process() {
|
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) {
|
while (_packets.size() > 0) {
|
||||||
NetworkPacket& packet = _packets.front();
|
NetworkPacket& packet = _packets.front();
|
||||||
processPacket(packet.getAddress(), packet.getData(), packet.getLength());
|
processPacket(packet.getAddress(), packet.getData(), packet.getLength());
|
||||||
|
|
Loading…
Reference in a new issue