Tweaked thread safety notice in the README
Querying the same document concurrently _could_ lead to problems, so lets just recommend users to not even try this.
This commit is contained in:
parent
4c79468091
commit
ac5cb3d24f
16
README.md
16
README.md
|
@ -177,13 +177,17 @@ process and bundled inside the Gem itself.
|
||||||
|
|
||||||
## Thread Safety
|
## Thread Safety
|
||||||
|
|
||||||
Documents parsed using Oga are thread-safe as long as they are not modified by
|
Oga does not use a unsynchronized global mutable state. As a result of this you
|
||||||
multiple threads at the same time. Querying documents using XPath can be done by
|
can parse/create documents concurrently without any problems. Modifying
|
||||||
multiple threads just fine. Write operations, such as removing attributes, are
|
documents concurrently can lead to bugs as these operations are not
|
||||||
_not_ thread-safe and should not be done by multiple threads at once.
|
synchronized.
|
||||||
|
|
||||||
It is advised that you do not share parsed documents between threads unless you
|
Some querying operations will cache data in instance variables, without
|
||||||
_really_ have to.
|
synchronization. An example is `Oga::XML::Element#namespace` which will cache an
|
||||||
|
element's namespace after the first call.
|
||||||
|
|
||||||
|
In general it's recommended to _not_ use the same document in multiple threads
|
||||||
|
at the same time.
|
||||||
|
|
||||||
## Namespace Support
|
## Namespace Support
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue