atlarge-research / opencraft

Other
4 stars 2 forks source link

Implement SortableBlockingQueue - [merged] #152

Closed jdonkervliet closed 4 years ago

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 12:19

Merges feature/custom-queue -> development

Add a sortable blocking queue for use in chunk streaming.

jdonkervliet commented 4 years ago

In GitLab by @larsdetombe on May 25, 2020, 12:21

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 109

Can you do the notNull checks in the code blocks instead?

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 12:30

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 109

These annotations were added automatically by Intellij code generation. I personal prefer them over manual checks (as the annotations check the code while writing instead of at runtime).

jdonkervliet commented 4 years ago

In GitLab by @larsdetombe on May 25, 2020, 12:35

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 212

Do you still want this timeout, or is this something for the future?

jdonkervliet commented 4 years ago

In GitLab by @larsdetombe on May 25, 2020, 12:38

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 326

Does this require correct ordering?

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on May 25, 2020, 12:42

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 37

Could you rename the comparator field to signify that this comparator is actually the reverse of the comparator that was supplied by the caller.

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 25, 2020, 12:43

Commented on src/test/java/net/glowstone/util/SortableBlockingQueueTest.java line 3

I wouldn't use a star import here. Not really a big deal but might be better if we don't use it

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 12:43

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 212

Yes, I'll add it in now. I was doubting about the implementation as the timeout would be reset when the thread is signaled.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 12:44

Commented on src/test/java/net/glowstone/util/SortableBlockingQueueTest.java line 3

Missed that one, it was automatically generated by Intellij on creating the test file.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 12:44

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 326

I am not sure, I'll look it up.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 12:48

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 326

It is never explicitly stated in the documentation, but I'll make it ordered just to be sure.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 13:02

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 212

changed this line in version 2 of the diff

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 13:02

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 37

changed this line in version 2 of the diff

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 13:02

Commented on src/test/java/net/glowstone/util/SortableBlockingQueueTest.java line 3

changed this line in version 2 of the diff

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 13:02

added 4 commits

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 13:04

added 1 commit

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on May 25, 2020, 13:20

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 20

The javadocs should properly reflect the fact that it gives different guarantees than you would normally expect when using a blocking queue.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 13:25

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 20

changed this line in version 4 of the diff

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 13:25

added 1 commit

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 13:26

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 20

I've added a line explaining that order is not guaranteed when insertions are performed in between sort calls.

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 25, 2020, 13:50

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 192

Can't you just call peek() here?

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 25, 2020, 13:50

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 224

Can't you just call element() here?

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 13:52

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 192

No, peek only retrieves the head, while poll removes it.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 13:52

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 224

No, element retrieves the head, while remove removes it.

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 25, 2020, 13:53

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 192

Ah didn't see that.

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 25, 2020, 13:53

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 224

Ah didn't see that.

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on May 25, 2020, 13:59

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 20

in between -> inbetween

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on May 25, 2020, 13:59

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 20

Besides that, looks good :)

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on May 25, 2020, 14:04

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 238

What is the order in which the elements are removed if there are multiple objects that are 'equal' to each other? Specifically whether the order changes after sorting, etc.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 14:46

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 20

I thought so as well, Intellij autocorrected it to 'in between'. I'll fix it right away.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 14:53

Commented on src/main/java/net/glowstone/util/SortableBlockingQueue.java line 238

I think the sort method of the ArrayList class guarantees that the order of elements that are equal does not change. However, in our application, there is no guarantee on the ordering of inserted elements. Therefore, we cannot provide a guarantee on the order of elements that are equal after sorting either.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 14:56

added 1 commit

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on May 25, 2020, 15:24

resolved all threads

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on May 25, 2020, 15:25

Commented on src/test/java/net/glowstone/util/SortableBlockingQueueTest.java line 585

Can you add a newline at the end of the file?

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 15:26

Commented on src/test/java/net/glowstone/util/SortableBlockingQueueTest.java line 585

Sure!

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 15:27

Commented on src/test/java/net/glowstone/util/SortableBlockingQueueTest.java line 585

changed this line in version 6 of the diff

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 25, 2020, 15:27

added 1 commit

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on May 25, 2020, 15:28

resolved all threads

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on May 25, 2020, 15:29

enabled an automatic merge when the pipeline for d9e48fd0bba2f62de6fc7481bf7d2bc3dc22e104 succeeds

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on May 25, 2020, 15:39

merged

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on May 25, 2020, 15:39

mentioned in commit 027324edf6c422bd53c6492418cf5cdd7f3e2d24