You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For initialization (onig_init()) use pthread_once() (POSIX) or InitOnceExecuteOnce() (WIN32).
For finalization (onig_end()) either do nothing (it's OK to leak some global state like Unicode tables) or use .fini section (ELF) or C++ destructors, or DllMain() (WIN32). This includes lazy initialization of the cclass table (which could have its own once-initializer), and the EUC/JIS Hiragana and Katakana property lists initialization (which could have its own once-initializer).
You can then leave onig_init() and onig_end() as empty stubs. For static-link archives it would help to have a --disable-thread option to not require -lpthread and to instead use a dumb once-initializer.
For USE_PARSE_TREE_NODE_RECYCLE use pthread_key_create() and pthread_setspecific() (POSIX) or thread-local storage and DllMain() (WIN32). Or just delete the USE_PARSE_TREE_NODE_RECYCLE code?
I think you can then drop all the THREAD_ATOMIC_START and THREAD_ATOMIC_END business and just declare that the remainder of thread safety is the application's job.
(I don't understand ONIG_STATE_DEC() though. Can you explain why it exists? reg->state doesn't look like a reference count...)
The text was updated successfully, but these errors were encountered:
Libraries aren't used just by programs. Sometimes (often!) libraries are used by other libraries. Ensuring that there is only one call (or non-racing calls) to a library's initializer or finalizer is then impossible. The situation for finalizers is worse because a library might call another's finalizer in its own, but this might happen as a result of a last dlcose(), and if the lower-level library was still in use by other callers in the same process... boom.
For ONIG_STATE_DEC() question.
This is because it avoids that regexp recompile and regexp search rise at the same time.
Regexp recompile API existed in old GNU regex. I supported it for compatibility.
However, I do not support it now. (USE_RECOMPILE_API is not defined.)
So, ONIG_STATE_INC() etc... is empty declarations.
For initialization (
onig_init()
) usepthread_once()
(POSIX) orInitOnceExecuteOnce()
(WIN32).For finalization (
onig_end()
) either do nothing (it's OK to leak some global state like Unicode tables) or use.fini
section (ELF) or C++ destructors, orDllMain()
(WIN32). This includes lazy initialization of the cclass table (which could have its own once-initializer), and the EUC/JIS Hiragana and Katakana property lists initialization (which could have its own once-initializer).You can then leave
onig_init()
andonig_end()
as empty stubs. For static-link archives it would help to have a--disable-thread
option to not require-lpthread
and to instead use a dumb once-initializer.For
USE_PARSE_TREE_NODE_RECYCLE
usepthread_key_create()
andpthread_setspecific()
(POSIX) or thread-local storage andDllMain()
(WIN32). Or just delete theUSE_PARSE_TREE_NODE_RECYCLE
code?I think you can then drop all the
THREAD_ATOMIC_START
andTHREAD_ATOMIC_END
business and just declare that the remainder of thread safety is the application's job.(I don't understand
ONIG_STATE_DEC()
though. Can you explain why it exists?reg->state
doesn't look like a reference count...)The text was updated successfully, but these errors were encountered: