This content has been marked as final. Show 2 replies
The queue object is allocated wherever the current allocation context is when you create the queue.
The queue's internal storage location depends on the constructor used. The constructor that only takes an int creates the internal storage in ImmortalMemory. The other constructor takes a MemoryArea in which the internal storage is to be allocated.
The queue only stores a reference to the object.
- the queue's internal storage must be able to store a reference to the object
In this case if the storage is in Immortal and the object in scope then you'll get a MemoryScopeException
- the reader must also be able to store a reference to the object read.
This isn't actually spelt out in the spec, but it's the obvious constraint. So if your reader is a plain JLT it will get an exception.
Basically to communicate between a NHRT using scope, to a JLT using heap you need an intermediary: a RTT using scope that can then copy the object for the JLT. Copy constructors come in handy for objects that you need to copy this way.
Hope that clarifies things somewhat.
Edited to add: actually I think there's a problem with the specification of the WFQ classes here. I need to check some details of the spec and our implementation. One thing to keep in mind, and this is something I misunderstood when first encountering the WFQs - the WFQs are a way to communicate between threads in the same memory area, NOT a way to communicate between threads in different memory areas.
Edited by: davidholmes on May 25, 2009 6:13 PM
you are right, I get an error when I pass int-, long-, float-values and other objects, but I don't get an exception, when I pass a byte-value to the queue, like:
This is what I have done until now, so I even didn't notice the restrictions. No Exception is thrown when one byte is passed. After comments on the existing restrictions I tried to pass an int-value or byte-arrays and I got the expected exceptions.
byte b = 112; queue.write();
'Where is the difference to passing one byte-value? Why do I not get any exceptions?