开发者

wxWidgets and locking resources

开发者 https://www.devze.com 2023-01-20 04:08 出处:网络
I\'m new to wxWidgets (C++), and threads for that matter.What should I be aware of concerning shared resources?Should I implement some sort of semaphore-based locking of resources that may be used by

I'm new to wxWidgets (C++), and threads for that matter. What should I be aware of concerning shared resources? Should I implement some sort of semaphore-based locking of resources that may be used by both the GUI thread and the worker th开发者_StackOverflowread(s)? Does wxWidgets offer some capability for dealing with this?


Not sure what your choice of threading library is at this point but in your case I'd use wxThread (see here & here for documentation).

What should I be aware of concerning shared resources?

See the Important notes for multithreaded applications part here for wxWidgets specific multi-threading issues.
Other than that the 'usual' concerns about shared resources apply.

Should I implement some sort of semaphore-based locking of resources that may be used by both the GUI thread and the worker thread(s)? Does wxWidgets offer some capability for dealing with this?

wxWidgets already implements a number of synchronization objects, see here.
As a side note prefer using the RAII locker helpers (wxMutexLocker, wxCriticalSectionLocker) instead of explicitly acquiring/releasing.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号