my windows appication uses pockesphinx in two different threads. I noticed
that in sphinxbase 0.7 the function err_get_logfp (in err.c) uses the windows
function TlsGetValue to get the FILE pointer to write the log to, so the
sphinx functions called from the thread in which sphinx initialization was
done write the log file correctly, while functions called in the other thread
always write log output in stderr.
So i ask: is this the only problem with multiple threads in 0.7 or there are
other issues, so multi threaded use should be avoided? (Up to now except for
the log writing everything seemed fine to me, though)
Thanks for any help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Logfp must be stderr by default for all threads. It can be thread-specifically
redefined
though. Applied little trick for that feature heh. Maybe this advanced thread-
specific implementation
could be made external for sphinxbase one day.
The idea behind it is that you need to set log file in EACH THREAD with
appropriate set_logfp call. In 0.6.1 the behaviour was broken because all
other threads where just silent (thread-specific variable was initialized by
-1 only once and was NULL in all other threads). That meant that all other
threads where silent. Maybe it was Linux-specific behaviour though and it
wasn't the case on Windinws. So this behaviour was fixed. All threads go to
stderr by default and all threads must be configured separately.
Please provide a patch if you will find a good solution on Windows.
So i ask: is this the only problem with multiple threads in 0.7 or there are
other issues, so multi threaded use should be avoided? (Up to now except for
the log writing everything seemed fine to me, though)
That should be the only thread complex issue. Mostly pocketsphinx must be
thread-safe.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you a lot for the long explanation. I solved by getting the log file
pointer in the first thread with err_get_logfp and setting it in the second
thread with err_set_logfp.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
my windows appication uses pockesphinx in two different threads. I noticed
that in sphinxbase 0.7 the function err_get_logfp (in err.c) uses the windows
function TlsGetValue to get the FILE pointer to write the log to, so the
sphinx functions called from the thread in which sphinx initialization was
done write the log file correctly, while functions called in the other thread
always write log output in stderr.
So i ask: is this the only problem with multiple threads in 0.7 or there are
other issues, so multi threaded use should be avoided? (Up to now except for
the log writing everything seemed fine to me, though)
Thanks for any help.
I just noticed that sphinxbase 6.1 also uses TlsGetValue, but in my
application it writes the log correctly.
Hello
This change was made in this revision:
r10758 | nshmyrev | 2011-01-09 03:19:43 +0300 (Вск, 09 Янв 2011) | 5 lines
Logfp must be stderr by default for all threads. It can be thread-specifically
redefined
though. Applied little trick for that feature heh. Maybe this advanced thread-
specific implementation
could be made external for sphinxbase one day.
The idea behind it is that you need to set log file in EACH THREAD with
appropriate set_logfp call. In 0.6.1 the behaviour was broken because all
other threads where just silent (thread-specific variable was initialized by
-1 only once and was NULL in all other threads). That meant that all other
threads where silent. Maybe it was Linux-specific behaviour though and it
wasn't the case on Windinws. So this behaviour was fixed. All threads go to
stderr by default and all threads must be configured separately.
Please provide a patch if you will find a good solution on Windows.
That should be the only thread complex issue. Mostly pocketsphinx must be
thread-safe.
Thank you a lot for the long explanation. I solved by getting the log file
pointer in the first thread with err_get_logfp and setting it in the second
thread with err_set_logfp.