--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
There is a module under this repo called chronicle-queue which has the v4 code.
The assumption is that the busy waiting thread is not only the monitor but the consumer as well. Ie there is only one thread involved. It is also the one to write any output to say another thread. Ie message in to message out there only needs to be one thread end to end.
Peter currently i'm using this https://github.com/OpenHFT/Chronicle-Queue isnt this the module you refered in your reply? (i simply dont know about any other chronicle-queue project).Also in order to create realistic comparison between busy loop and watch service (event loop) approaches, i'd like to know if it is common to run the busy loop in your worker thread? I've read somewhere that one must run a separate thread (assigned to a dedicated core), so i suppose that when a worker thread wants to wait for an update it literally wait()'s on some object which is then notified from the busy loop runing in a different thread than the worker right? or it works differently?
--
The general approach is to attempt to read a message and the method returns false if there is no message.
If you are using the try-with-resource readingDocument you have to call isPresent()
Here is an example of where you provide a lambda to read the bytes of your message which will return true if a message is present.
default boolean readBytes(@NotNull ReadBytesMarshallable reader) {
try (DocumentContext dc = readingDocument()) {
if (!dc.isPresent())
return false;
reader.readMarshallable(dc.wire().bytes());
}
return true;
}
You can do it without creating object at all.
Note: whenever a method is called with a DTO you actually get the same object passed each time so if you want to retain data it must be copied.
On the upside, the same object is reused.
Peter.