Add support for multi-threaded xpath evaluation#191
Add support for multi-threaded xpath evaluation#191maartendeprez wants to merge 2 commits intoKWARC:masterfrom
Conversation
|
Thank you, this appears to be a very useful extension. Could I also request that you mirror our one findnodes test here: rust-libxml/tests/xpath_tests.rs Lines 122 to 144 in 4224fd9 With a similar entry inside |
readonly methods.
|
Copied and adapted the tests and added the required read-only methods to implement this. I left two tests commented out in the read-only version:
Both require the |
|
Hm, upon further consideration, my design is not correct at all, since the |
Is there anything I can help with? The main background I can offer is that multi-threaded workflows on the Mixing the read-only API of the create with the writable API is likely something that needs some significant redesign work, as it wasn't an original desire. My thinking at the time was, if you need even one writable operation, do not use the |
|
My thinking at the moment is that for the read-only API, I'll need to do away with all the reference counting stuff (i.e. the Excluding mixed use of the writable and read-only APIs at the type level, is what i was alluding to in issue 192. That would need to be done in a separate PR. In rust when we're "not supposed to" do something that would cause undefined behavior, the API is usually designed in such a way that the compiler will not allow us to do so without writing "unsafe" code, ensuring that "Safe Rust can’t cause Undefined Behavior". On the other hand, if we want to allow mixing read-only and read-write APIs, it seems possible to leverage the rust type-system to enforce the contract on top of the If that kind of API is feasible, it would provide a completely different (arguably lower-level) API. If we go through with this, I think we should separate the bindings in a |
The
readonlymodule provides support for multi-threaded read-only operations over a parsed document. However, thefindnodesmethod takes a shared reference to aDocument, which is not readonly and therefore notSend+Sync. This makes it impossible, currently, to evaluate xpaths over the document from multiple threads.This PR changes that by introducing a read-only version of
Document,ContextandObject, as well as afindnodes_readonlymethod onRoNode.