-
Notifications
You must be signed in to change notification settings - Fork 83
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thread Safety #36
Comments
To this aim, it can be convenient to pack global vars referred to single parsed file into a derived type allowing each thread to have its own global vars set. I have successful used this approach into Lib_VTK_IO. See you soon. |
I have been thinking about this a little bit. There's probably no way to make this happen without breaking backward compatibility, so here are some thoughts on a possible implementation that has a somewhat similar usage (this could be the 4.0 release):
Current usage: program test
use json_module
implicit none
type(json_value),pointer :: p
call json_initialize() !initialize the module
call json_create_object(p,'') !create the root
call json_add(p,'year',1805) !add some data
call json_add(p,'value',1.0d0) !add some data
call json_print(p,'test.json') !write it to a file
call json_destroy(p) !cleanup
end program test Proposed usage: program test
use json_module
implicit none
type(json_core) :: json !<--have to declare this
type(json_value),pointer :: p
call json%initialize() !initialize this instance
call json%create_object(p,'') !create the root
call json%add(p,'year',1805) !add some data
call json%add(p,'value',1.0d0) !add some data
call json%print(p,'test.json') !write it to a file
call json%destroy(p) !cleanup
end program test It has the advantage of being fairly easy to update your code (declare a Note that Is this clunky though? Is there a better way? |
I'm going to start implementing this after #170 is finished. |
This is coming along nicely on the thread-safe branch. |
Done. |
Currently the module is not thread safe (due to the global variables used when parsing a file and to manage the error conditions). Consider refactoring the code to make it thread safe.
The text was updated successfully, but these errors were encountered: