[help]About wxFileConfig multi process read and write problem Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
lfjking
Earned some good credits
Earned some good credits
Posts: 102
Joined: Mon Nov 14, 2016 1:35 pm

[help]About wxFileConfig multi process read and write problem

Post by lfjking »

wxFileConfig can R-W the file Ini.
but
At the same time there are multiple processes to read and write the same Ini file will be wrong

How to solve this problem? Help!
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: [help]About wxFileConfig multi process read and write problem

Post by doublemax »

I guess you're using wxFileConfig for something it wasn't designed for. wxFileConfig just isn't thread-safe. If you really want to use it, you'd have to write a wrapper around it that protects all methods with a mutex.
Use the source, Luke!
lfjking
Earned some good credits
Earned some good credits
Posts: 102
Joined: Mon Nov 14, 2016 1:35 pm

Re: [help]About wxFileConfig multi process read and write problem

Post by lfjking »

doublemax wrote:I guess you're using wxFileConfig for something it wasn't designed for. wxFileConfig just isn't thread-safe. If you really want to use it, you'd have to write a wrapper around it that protects all methods with a mutex.

Yes, may be I must do it.
I thought wxfileconfig was thread-safe
Later encountered a problem before they know it is not

thinks
lfjking
Earned some good credits
Earned some good credits
Posts: 102
Joined: Mon Nov 14, 2016 1:35 pm

Re: [help]About wxFileConfig multi process read and write problem

Post by lfjking »

doublemax wrote:I guess you're using wxFileConfig for something it wasn't designed for. wxFileConfig just isn't thread-safe. If you really want to use it, you'd have to write a wrapper around it that protects all methods with a mutex.

dear doublemax :D

Give me a suggestion that I want to use the security configuration file, which will be better with wxWidgets, In addition to the registry
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: [help]About wxFileConfig multi process read and write problem

Post by doublemax »

I misread your original question, i thought you were talking about multiple threads, but now i realize you were talking about multiple processes.

This makes the problem even more difficult and the easiest solution that comes to mind would be a sqlite database (with wxSQLite3) that's shared among all processes.

https://sqlite.org/faq.html#q5
Use the source, Luke!
lfjking
Earned some good credits
Earned some good credits
Posts: 102
Joined: Mon Nov 14, 2016 1:35 pm

Re: [help]About wxFileConfig multi process read and write problem

Post by lfjking »

doublemax wrote:I misread your original question, i thought you were talking about multiple threads, but now i realize you were talking about multiple processes.

This makes the problem even more difficult and the easiest solution that comes to mind would be a sqlite database (with wxSQLite3) that's shared among all processes.

https://sqlite.org/faq.html#q5

thanks very mush :D
lfjking
Earned some good credits
Earned some good credits
Posts: 102
Joined: Mon Nov 14, 2016 1:35 pm

Re: [help]About wxFileConfig multi process read and write problem

Post by lfjking »

doublemax wrote:I misread your original question, i thought you were talking about multiple threads, but now i realize you were talking about multiple processes.

This makes the problem even more difficult and the easiest solution that comes to mind would be a sqlite database (with wxSQLite3) that's shared among all processes.

https://sqlite.org/faq.html#q5
doublemax

In addition to wxSQLite3
How can we use WX to complete it?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: [help]About wxFileConfig multi process read and write problem

Post by doublemax »

How can we use WX to complete it?
Sorry, i don't understand the question. What more do you need?
Use the source, Luke!
lfjking
Earned some good credits
Earned some good credits
Posts: 102
Joined: Mon Nov 14, 2016 1:35 pm

Re: [help]About wxFileConfig multi process read and write problem

Post by lfjking »

doublemax wrote:
How can we use WX to complete it?
Sorry, i don't understand the question. What more do you need?
I would like to see whether the wxWidgets package has a similar CreateMutex API.
Or there is no relevant class to achieve process security
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: [help]About wxFileConfig multi process read and write problem

Post by doublemax »

I would like to see whether the wxWidgets package has a similar CreateMutex API.
Or there is no relevant class to achieve process security
Are we still talking about the problem of shared file access? In that case, you don't have to do anything, sqlite does it internally. Just use the same database file (locally or over a network share) from all applications and all will be able to read/write to it.
Use the source, Luke!
lfjking
Earned some good credits
Earned some good credits
Posts: 102
Joined: Mon Nov 14, 2016 1:35 pm

Re: [help]About wxFileConfig multi process read and write problem

Post by lfjking »

doublemax wrote:
I would like to see whether the wxWidgets package has a similar CreateMutex API.
Or there is no relevant class to achieve process security
Are we still talking about the problem of shared file access? In that case, you don't have to do anything, sqlite does it internally. Just use the same database file (locally or over a network share) from all applications and all will be able to read/write to it.

Yes, it's better to use SQLite
The use of the API platform is also a problem
Well, it's worth it, even if it's going to make it bigger

thanks :D :D
Post Reply