C++ Thread Safe Integer

前端 未结 6 630
醉话见心
醉话见心 2021-02-07 06:57

I have currently created a C++ class for a thread safe integer which simply stores an integer privately and has public get a set functions which use a boost::mutex to ensure tha

6条回答
  •  执笔经年
    2021-02-07 07:07

    As you're using GCC, and depending on what operations you want to perform on the integer, you might get away with GCC's atomic builtins.

    These might be a bit faster than mutexes, but in some cases still a lot slower than "normal" operations.

提交回复
热议问题