[geary/mjog/logging-improvements: 17/23] Geary.Logging: Let callers determine threading safety for log_listener
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/logging-improvements: 17/23] Geary.Logging: Let callers determine threading safety for log_listener
- Date: Thu, 16 Apr 2020 09:04:05 +0000 (UTC)
commit 2fada87a72b469fff7ff81d8b86484bf31585139
Author: Michael Gratton <mike vee net>
Date: Thu Apr 16 17:11:53 2020 +1000
Geary.Logging: Let callers determine threading safety for log_listener
Rather than scheduling calling a registered log_listener on the default
main loop context, let the listener implementation handle that in
whatever way they want.
src/engine/util/util-logging.vala | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/src/engine/util/util-logging.vala b/src/engine/util/util-logging.vala
index e6c1cb90..5294355b 100644
--- a/src/engine/util/util-logging.vala
+++ b/src/engine/util/util-logging.vala
@@ -62,6 +62,9 @@ namespace Geary.Logging {
* For any log records to be created, {@link default_log_writer}
* must be set as the GLib structured log writer.
*
+ * Note that the given function *must* be thread-safe, since
+ * logging can occur on multiple threads at once.
+ *
* @see default_log_writer
*/
public void set_log_listener(LogRecord? new_listener) {
@@ -235,13 +238,8 @@ namespace Geary.Logging {
// records.
old_record = null;
- // Ensure the listener is updated on the main loop only, since
- // this could be getting called from other threads.
if (Logging.listener != null) {
- GLib.MainContext.default().invoke(() => {
- Logging.listener(record);
- return GLib.Source.REMOVE;
- });
+ Logging.listener(record);
}
write_record(record, levels);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]