I did not find parseJson() in the IDF and so cannot answer your specific question.
In general terms however:
For a library to be thread safe then there must be no 'memory' between function calls contained within library variables. It must not be possible for the library to share some resource (internal variable and/or device) with another thread.
Executable code is not the issue, it is the shared variables and/or shared device.
So a library which works this way:
Code: Select all
pMyJsonDecode = startJson(aString);
nextValue = nextJsonValue(pMyJsonDecode);
Is likely to be thread safe as the parsing 'context' is being stored in pMyJsonDecode. The libary itself has no internal memory. The library gives you the item to be remembered and on next use you remind the library what it was up too.
If however a function uses data previously setup by itself or another library function (& not passed back to the libary user) then it is likely that the library is not thread safe.
Typically if a libary contains file scope variables and/or static variables within a function then the library is probably not thread safe (a number of exceptions including when the library uses semaphore etc to control access to shared items).
The typical 'thread unsafe' library example is strtok()
http://www.cplusplus.com/reference/cstring/strtok/. In the old days strtok() was not thread safe as you initialised the process by passing your string and then continued the process by passing NULL. The library function strtok() remembered your string and so was not thread safe.
Note that these days strtok() is typically thread safe as the supporting plaform keeps a local copy of library variables for each thread.
This thread memory only works for
some standard C library functions however.