Home  >  Q&A  >  body text

Linux C++如何编写线程安全库?

Linux C++如何编写线程安全库?
看了当析构函数遇到多线程──C++ 中线程安全的对象回调这篇文章后,还是不太明白如何去做,是否有一些实际的例子可以学习一下?

黄舟黄舟2744 days ago1252

reply all(4)I'll reply

  • 阿神

    阿神2017-04-17 11:42:19

    Here is a tutorial

    Here are examples

    reply
    0
  • 阿神

    阿神2017-04-17 11:42:19

    He means to use shared_ptr wherever possible (ignore me

    reply
    0
  • 黄舟

    黄舟2017-04-17 11:42:19

    Borrow the answer from how to make an application thread safe?.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:42:19

    1 If a function can use local variables, try to use local variables. These variables allocated on the stack do not affect a function being called in different places.
    2 If there is data shared by multiple functions, the most basic method is to lock the variables shared by multiple functions.
    3 Consider using thread local storage

    reply
    0
  • Cancelreply