5

如果我的接收器是线程安全的,我可以从多个线程写入 boost::iostreams::stream 而不进行同步吗?

class my_sink : boost::iostreams::sink {
public:
    my_sink(param p) {}

    std::streamsize write(const char_type *s, std::streamsize n) {
        // thread-safe implementation
    }
};

boost::iostreams::stream<my_sink> my_stream(parameter);

void thread1() {
    my_stream << "some output";
}

void thread2() {
    my_stream << "some output";
}
4

0 回答 0