PCRE 库线程安全吗?如果没有,你推荐哪个? [英] Is the PCRE library thread-safe? If not, which do you recommend?

查看:73
本文介绍了PCRE 库线程安全吗?如果没有,你推荐哪个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于 C/C++,PCRE 库线程安全吗?如果PCRE是线程安全的,性能上有问题吗?

For C/C++, is the PCRE library thread-safe? If PCRE is thread-safe, is there any problem in performance?

推荐答案

PCRE 文档来看:

多线程

PCRE 函数可用于多线程应用程序,具有内存管理函数指向的条件是pcre_malloc、pcre_free、pcre_stack_malloc 和 pcre_stack_free,以及pcre_callout 和指向的标注和堆栈检查函数pcre_stack_guard,由所有线程共享.

The PCRE functions can be used in multi-threading applications, with the proviso that the memory management functions pointed to by pcre_malloc, pcre_free, pcre_stack_malloc, and pcre_stack_free, and the callout and stack-checking functions pointed to by pcre_callout and pcre_stack_guard, are shared by all threads.

正则表达式的编译形式在匹配过程中不会改变,因此多个线程可以安全地使用相同的编译模式一下子.

The compiled form of a regular expression is not altered during matching, so the same compiled pattern can safely be used by several threads at once.

如果正在使用即时优化功能,则每个线程都需要单独的内存堆栈区域.查看 pcrejit 文档了解更多详情.

If the just-in-time optimization feature is being used, it needs separate memory stack areas for each thread. See the pcrejit documentation for more details.

所有这一切意味着,如果您小心,答案是是的,PCRE 库是线程安全的".

All of this means that if you are careful, the answer is 'Yes, the PCRE library is thread-safe'.

这篇关于PCRE 库线程安全吗?如果没有,你推荐哪个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆