mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-04-09 21:32:37 +02:00
Also use the queue in SMTPClient when not threading.
This commit is contained in:
parent
4a35fb9b44
commit
40e20146f6
@ -163,6 +163,11 @@ void SMTPClient::send_email(const Ref<EMail> &p_email) {
|
|||||||
|
|
||||||
_worker_semaphore.post();
|
_worker_semaphore.post();
|
||||||
} else {
|
} else {
|
||||||
|
if (_current_session_email.is_valid()) {
|
||||||
|
_mail_queue.push_back(p_email);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_send_email(p_email);
|
_send_email(p_email);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,7 +205,7 @@ void SMTPClient::_send_email(const Ref<EMail> &p_email) {
|
|||||||
emit_signal("result", result);
|
emit_signal("result", result);
|
||||||
|
|
||||||
if (!should_use_threading()) {
|
if (!should_use_threading()) {
|
||||||
set_process(false);
|
_no_thread_next_email();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +229,7 @@ void SMTPClient::_send_email(const Ref<EMail> &p_email) {
|
|||||||
emit_signal("result", result);
|
emit_signal("result", result);
|
||||||
|
|
||||||
if (!should_use_threading()) {
|
if (!should_use_threading()) {
|
||||||
set_process(false);
|
_no_thread_next_email();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -342,7 +347,7 @@ void SMTPClient::close_connection() {
|
|||||||
_current_tls_established = false;
|
_current_tls_established = false;
|
||||||
|
|
||||||
if (!should_use_threading()) {
|
if (!should_use_threading()) {
|
||||||
set_process(false);
|
_no_thread_next_email();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,6 +553,27 @@ void SMTPClient::_process_email() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SMTPClient::_no_thread_next_email() {
|
||||||
|
if (should_use_threading()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<EMail> mail;
|
||||||
|
|
||||||
|
int size = _mail_queue.size();
|
||||||
|
if (size > 0) {
|
||||||
|
mail = _mail_queue[0];
|
||||||
|
_mail_queue.remove(0);
|
||||||
|
} else {
|
||||||
|
set_process(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mail.is_valid()) {
|
||||||
|
_send_email(mail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SMTPClient::_worker_thread_func(void *user_data) {
|
void SMTPClient::_worker_thread_func(void *user_data) {
|
||||||
SMTPClient *self = (SMTPClient *)user_data;
|
SMTPClient *self = (SMTPClient *)user_data;
|
||||||
|
|
||||||
|
@ -142,6 +142,7 @@ protected:
|
|||||||
String encode_password();
|
String encode_password();
|
||||||
|
|
||||||
void _process_email();
|
void _process_email();
|
||||||
|
void _no_thread_next_email();
|
||||||
|
|
||||||
static void _worker_thread_func(void *user_data);
|
static void _worker_thread_func(void *user_data);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user