mirror of
https://github.com/Tha14/toxic.git
synced 2025-07-03 01:06:44 +02:00
Refactor message queue
We now attempt to send all queued messages per call to cqueue_try_send() instead of just the oldest message in the queue. This speeds things up substantially. Also fixed a very unlikely bug where the read receipt might wrap around to zero which we used as a reserved value for an unsent message
This commit is contained in:
@ -947,6 +947,7 @@ static void do_toxic(Tox *m)
|
||||
|
||||
tox_iterate(m, NULL);
|
||||
do_tox_connection(m);
|
||||
|
||||
pthread_mutex_unlock(&Winthread.lock);
|
||||
}
|
||||
|
||||
@ -985,9 +986,7 @@ void *thread_cqueue(void *data)
|
||||
while (true) {
|
||||
pthread_mutex_lock(&Winthread.lock);
|
||||
|
||||
size_t i;
|
||||
|
||||
for (i = 2; i < MAX_WINDOWS_NUM; ++i) {
|
||||
for (size_t i = 2; i < MAX_WINDOWS_NUM; ++i) {
|
||||
ToxWindow *toxwin = get_window_ptr(i);
|
||||
|
||||
if ((toxwin != NULL) && (toxwin->type == WINDOW_TYPE_CHAT)
|
||||
@ -998,7 +997,7 @@ void *thread_cqueue(void *data)
|
||||
|
||||
pthread_mutex_unlock(&Winthread.lock);
|
||||
|
||||
sleep_thread(4000L);
|
||||
sleep_thread(750000L); // 0.75 seconds
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user