c++ - 64 bit Linux g++ passing STRUCT btw two threads via pipe -


i have c++ app running on 64 bit linux. planning pass simple struct data (without virtual function in it) 1 thread thread ( in same process) via pipe without special consideration of alignment. basically, sending side sends amount of sizeof(struct) bytes. , recving side cast bytes struct. there no concurrent access/atomicity concern. , there won't plan pass data different process or remote machine in future.

i positive code work expected.

however, opinions experts of on approach see if there potential issues. ( testing might not disclose them in case).

i rather use std::deque<mystruct>, , use simple synchronisation mechanism std::condition_variable notify consumer thread available data, plus std:::mutex make writing/reading to/from queue thread safe.

i think should far more efficient pipe handle , of write()/read() operations coming along such technique.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -