Stiffstream / json_dto

A small header-only library for converting data between json representation and c++ structs
BSD 3-Clause "New" or "Revised" License
149 stars 18 forks source link

Is json_dto thread-safe? #3

Closed davidwed closed 5 years ago

eao197 commented 5 years ago

What do you mean?

davidwed commented 5 years ago

Are all classes in json_dto designed to be reentrant ( like RapidJSON )? So I can call json_dto::from_json(), json_dto::to_json() from different threads ?

eao197 commented 5 years ago

IIRC, json_dto-related stuff are stateless. It means that during the call of, for example, json_dto::from_json there is only local state, that doesn't go out of call scope. So it is safe to call json_dto::from_json or json_to::to_json from different threads.

But json_dto doesn't protect the object being serialized/deserialized. So if you call json_dto::to_json on one thread and modify the same object from another thread, then json_dto won't protect your object from data races.

davidwed commented 5 years ago

Thx.