pulsar-rs icon indicating copy to clipboard operation
pulsar-rs copied to clipboard

Mutex in producer::TopicProducer is unnecessary

Open dojiong opened this issue 1 year ago • 0 comments

In the definition of TopicProducer(producer.rs), batch is Option<Mutex<Batch>>. But there is no scenes requires this lock, all using mut reference of TopicProducer when sending messages.

    // putting it in a mutex because we must send multiple messages at once
    // while we might be pushing more messages from elsewhere
    batch: Option<Mutex<Batch>>,

Same problem with Batch (here).

    // put it in a mutex because the design of Producer requires an immutable TopicProducer,
    // so we cannot have a mutable Batch in a send_raw(&mut self, ...)
    pub storage: Mutex<BatchStorage>,

Is this a unfinished design for shareable producer?

dojiong avatar Jun 13 '23 02:06 dojiong