Skip to content

On threads and global variables #13

Open
@dwarring

Description

@dwarring

globals

LibXML has a fair number of global variables, including such things as error states, parser callbacks, and options.

Perl 5 does try to compensate, and improve reentrant behaviour, by save and restoring state, resetting options etc.

It just a matter of how hard you push it. Something's will cause problems in a single threaded environment, e.g. trying to work with multiple concurrent push or pull parsers.

threading

In the simple case LibXML doesn't support concurrent update of read/update +DOM threads across threads. There's a native lock method that's designed to help with this. This uses libXML mutexs to lock between threads. The nodes must be identical - not just in the same tree. The simplist case is to lock the document or document root element.

LibXML has been retrofitted to context switch between threads, saving and restoring state, under the control of a mutex lock. This means that some cases, tasks which aren't re-entrant may not cause contention when performed across threads.

Locking and update needs to be explored and tested more before being documented. I'd at least like to try and come up with a simple scenario where a re-entrant problem is solved by running across threads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions