From 38be9d5fed172ab8ee24c8c2cb0c94fb41d02e37 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 22 Dec 2013 12:29:16 +0100 Subject: msg: add some comments about thread-safety --- common/msg.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'common') diff --git a/common/msg.c b/common/msg.c index ff3071a92c..841fab30c7 100644 --- a/common/msg.c +++ b/common/msg.c @@ -101,6 +101,7 @@ static void update_loglevel(struct mp_log *log) } // Return whether the message at this verbosity level would be actually printed. +// Thread-safety: see mp_msg(). bool mp_msg_test(struct mp_log *log, int lev) { mp_memory_barrier(); @@ -173,6 +174,8 @@ void mp_msg_va(struct mp_log *log, int lev, const char *format, va_list va) // parent's name. If the name starts with "/", the parent's name is not // prefixed (except in verbose mode), and if it starts with "!", the name is // not printed at all (except in verbose mode). +// Thread-safety: fully thread-safe, but keep in mind that talloc is not (so +// talloc_ctx must be owned by the current thread). struct mp_log *mp_log_new(void *talloc_ctx, struct mp_log *parent, const char *name) { @@ -262,6 +265,9 @@ void mp_msg_uninit(struct mpv_global *global) global->log = NULL; } +// Thread-safety: fully thread-safe, but keep in mind that the lifetime of +// log must be guaranteed during the call. +// Never call this from signal handlers. void mp_msg(struct mp_log *log, int lev, const char *format, ...) { va_list va; -- cgit v1.2.3