BeeHive icon indicating copy to clipboard operation
BeeHive copied to clipboard

BHConfig 线程安全问题

Open raomengyun opened this issue 8 years ago • 4 comments

用 BHConfig 做一些项目公共配置数据的存储,但是发现其不是线程安全的😂,外部去约束 BHConfig 的线程安全做起来相当麻烦,有什么好的方案可以解决么?

raomengyun avatar Sep 27 '17 09:09 raomengyun

@interface BHConfig()

@property(nonatomic, strong) NSMutableDictionary *config;

@end

codesourse avatar Feb 09 '18 07:02 codesourse

config会出现线程安全问题,多线程下同时操作这个字典,那不是呵呵

codesourse avatar Feb 09 '18 07:02 codesourse

Multithreaded is not safe. You can refer to https://github.com/codesourse/WERouter

codesourse avatar Feb 09 '18 07:02 codesourse

@codesourse This is my raw and dump idea: Make a wrapper class, and use composite pattern to wrap BHConfig class inside it. Then just make the wrapper class Multithreaded safe. Access the wrapper class instead of BHConfig class. This maybe the balance of not changing BHConfig class itself and making it Multithreaded safe.

MemoryReload avatar Mar 02 '18 01:03 MemoryReload