Is ofstream thread safe?

后端 未结 3 1062
你的背包
你的背包 2020-12-10 19:00

I am working on a program, which uses multiple std::ifstreams for reading a binary file, one std::ifstream for each thread. Now I need to know, if

3条回答
  •  情书的邮戳
    2020-12-10 19:22

    If I haven't misunderstood you - no, nothing in the standard library is thread safe (except the std::thread specific things, of course (from C++11 and later)). You need additional synchronization.

    Even more - if there are several processes, reading from/writing to these files, you need to lock the files, to sync the access.

提交回复
热议问题