portability.rst (jansson-2.13.1.tar.bz2) | : | portability.rst (jansson-2.14.tar.bz2) | ||
---|---|---|---|---|
*********** | .. _thread-safety: | |||
Portability | ||||
*********** | ||||
.. _portability-thread-safety: | ||||
************* | ||||
Thread safety | Thread safety | |||
************* | ||||
Jansson as a library is thread safe and has no mutable global state. | Jansson as a library is thread safe and has no mutable global state. | |||
The only exceptions are the hash function seed and memory allocation | The only exceptions are the hash function seed and memory allocation | |||
functions, see below. | functions, see below. | |||
There's no locking performed inside Jansson's code. **Read-only** | There's no locking performed inside Jansson's code. **Read-only** | |||
access to JSON values shared by multiple threads is safe, but | access to JSON values shared by multiple threads is safe, but | |||
**mutating** a JSON value that's shared by multiple threads is not. A | **mutating** a JSON value that's shared by multiple threads is not. A | |||
multithreaded program must perform its own locking if JSON values | multithreaded program must perform its own locking if JSON values | |||
shared by multiple threads are mutated. | shared by multiple threads are mutated. | |||
skipping to change at line 64 | skipping to change at line 61 | |||
``json_object_seed(0)`` , especially if you're unsure whether the | ``json_object_seed(0)`` , especially if you're unsure whether the | |||
initialization is thread safe on your platform. | initialization is thread safe on your platform. | |||
Memory allocation functions | Memory allocation functions | |||
=========================== | =========================== | |||
Memory allocation functions should be set at most once, and only on | Memory allocation functions should be set at most once, and only on | |||
program startup. See :ref:`apiref-custom-memory-allocation`. | program startup. See :ref:`apiref-custom-memory-allocation`. | |||
Locale | Locale | |||
====== | ||||
Jansson works fine under any locale. | Jansson works fine under any locale. | |||
However, if the host program is multithreaded and uses ``setlocale()`` | However, if the host program is multithreaded and uses ``setlocale()`` | |||
to switch the locale in one thread while Jansson is currently encoding | to switch the locale in one thread while Jansson is currently encoding | |||
or decoding JSON data in another thread, the result may be wrong or | or decoding JSON data in another thread, the result may be wrong or | |||
the program may even crash. | the program may even crash. | |||
Jansson uses locale specific functions for certain string conversions | Jansson uses locale specific functions for certain string conversions | |||
in the encoder and decoder, and then converts the locale specific | in the encoder and decoder, and then converts the locale specific | |||
End of changes. 4 change blocks. | ||||
5 lines changed or deleted | 4 lines changed or added |