gpt4 book ai didi

c++ - 开罗图形库是可重入的吗?

转载 作者:太空宇宙 更新时间:2023-11-04 02:02:17 25 4
gpt4 key购买 nike

如果我在两个不同的线程中使用两个不同的 cairo_t(以及相关的 cairo_surface_t 等)对象,我能保证不会因为共享全局状态而出现竞争条件吗?

我是否也可以将 cairo_t 对象从一个线程正式传递到另一个线程而不会出现任何意外行为(可能由线程本地存储引起)?

最佳答案

这个错误跟踪讨论应该可以回答您的问题:https://bugs.freedesktop.org/show_bug.cgi?id=74355

<强>1。开罗应该是可重入的

Uli Schlachter 2014-02-03 18:25:06 UTC

(In reply to comment #0)

  1. share a single cairo_surface_t between the threads, and have each thread draw using its own cairo_t. This crashes, but maybe I'm hoping for too much (although an image surface is essentially just a big array of bytes that should be writable from multiple threads).

当然,只是一个数组。只要您期望任何东西,这就有效 喜欢有用的结果。开罗应该是线程安全的,只要 线程不共享任何状态(好吧,这是一个 过于简单化,但您的第一种方法不应该起作用)。

<强>2。线程本地存储可能导致 Pixman 崩溃

Søren Sandmann Pedersen 2014-02-17 16:49:02 UTC

It is possible that pixman's support for TLS on Windows is simply buggy; it may be that not a lot of people have been using pixman in a multithreaded way on Windows (or have worked around the problem in some way). We will need some kind of way to reproduce the issue to know.

In pixman 0.32.0 and later there is a test program called 'thread-test' that may reproduce this issue if you can get it running on Windows.

作为一项政策,您应该始终将第三方库视为不安全的,除非证明并非如此。

关于c++ - 开罗图形库是可重入的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25726017/

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