pipe write thread-safe