viabtc / viabtc_exchange_server

A trading engine with high-speed performance and real-time notification
MIT License
2.67k stars 1.49k forks source link

How to ensure that dict table can be updated at the same time under concurrency condition #212

Open kavonm opened 4 years ago

kavonm commented 4 years ago

Hi, @haipome

I noticed that almost all the major structures such as market, balance, sql, trade, etc. are based on dict_t data structure. However, if more than one entry are to be added, deleted or replaced, There is no protection to resolve the conflict about updating the same dict table. Maybe we can use pthread mutex to ensure that. Could you please help explain that?

‘static' variable still has no contribution to multiple threading security. such as static dict_t dict_market; static dict_t dict_cache; static dict_t *dict_sql; etc.

Thanks so much!