可重入函数(reentrant function)与线程安全函数(thread-safe function)有时容易混淆,而且各种文档中的解释也不是很清楚,这里根据笔者的经验来说明一下。
基于16个网页-相关网页
Thread-Safe Function:A function that may be safely invoked concurrently by multiple threads.
线程安全函数不一定是可重入函数。
Note that readdir is not thread-safe, because the returned structure is a static variable stored in the function library.
请注意,readdir不是线程安全的,因为所返回的结构是存储在函数库中的一个静态变量。
Keep in mind that the timer callback function is executed on a worker thread, so you'll want to ensure that you have thread-safe access to the state object.
记住定时回调功能是在一个工作者线程上执行的,所以你必须确保访问state对象的线程安全。
应用推荐