You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@eventmesh.apache.org by "pandaapo (via GitHub)" <gi...@apache.org> on 2023/05/21 02:28:32 UTC

[GitHub] [eventmesh] pandaapo commented on a diff in pull request #3984: [ISSUE #3983] Optimize MessageQueue

pandaapo commented on code in PR #3984:
URL: https://github.com/apache/eventmesh/pull/3984#discussion_r1199684903


##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -54,22 +57,23 @@ public MessageQueue(int capacity) {
         }
         this.items = new MessageEntity[capacity];
         this.lock = new ReentrantLock();
-        this.notEmpty = lock.newCondition();
-        this.notFull = lock.newCondition();
+        this.isEmpty = lock.newCondition();
+        this.isFull = lock.newCondition();
     }

Review Comment:
   These modification will confuse the developer or user. We name it `notFull` in situation of waiting on a full queue until not full, `notEmpty`  in situation of waiting on a empty queue util not empty. This naming method comes from jdk. https://github.com/openjdk/jdk/blob/a0f4a948bb76ce5ea11d8fe08e788ed43516ca4e/src/java.base/share/classes/java/util/concurrent/ArrayBlockingQueue.java#L370



##########
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java:
##########
@@ -24,24 +24,27 @@
 
 import com.google.common.base.Preconditions;
 
+import lombok.Getter;
+
 /**
- * This is a block queue, can get entity by offset. The queue is a FIFO data structure.
+ *  Represents a message queue that stores instances of MessageEntity.
  */

Review Comment:
   I think the original comment seems to be more clear. It can make developer or user easier and faster understand this class. And the modifications to `put(MessageEntity messageEntity)`, `take()`, `getByOffset(long offset)` are in the same situation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org