gpt4 book ai didi

c# - Saxon 9 Compiled Transform 的线程安全

转载 作者:太空宇宙 更新时间:2023-11-03 13:20:57 24 4
gpt4 key购买 nike

使用 Saxon 9 HE,编译样式表(在 .Net 中)需要几秒钟。

任何人都可以验证编译后的转换是线程安全的吗?即如果我编译样式表并保留实例以在将来调用。从多个线程同时调用这个已编译的 Transform 实例会导致任何问题吗?

XsltTransformer transformer = proc.NewXsltCompiler().Compile(new Uri("file:///" + styleSheet)).Load();

//Store transformer instance as class variable and reuse it to eliminate compilation time

最佳答案

参见 the documentation on saxonica.com ,你只需要编译一次 XsltExecutable ex = proc.NewXsltCompiler().Compile(new Uri("file:///"+ styleSheet)); 然后就可以使用 XsltExecutable 在多个线程中:“XsltExecutable 是不可变的,因此是线程安全的。”。

关于 XsltTransformerit says “不应在多个线程中同时使用 XsltTransformer。但是,在单个线程中重用该对象以多次运行相同的样式表是安全的。”。

关于c# - Saxon 9 Compiled Transform 的线程安全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24231501/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com