-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Allow sharing queues between tile layers. #1100
Conversation
@aashish24 This is intended to be the first of a few improvements that will allow better buffering of multiple tile sources. Follow on work will include an explicit A/B buffered tile layer. |
Although you could sort of share the fetch queue between tile layers, it wouldn't really share properly without a custom needed function. This explicitly supports sharing a fetch queue between tile layers. This allows, for instance, multiple layers that access the same server to have a single fetch queue so that the number of requests against the server is limited (usually to 6) rather than that number multiplied by the number of layers.
get: function () { return m_this._queue; }, | ||
set: function (queue) { | ||
if (m_this._queue !== queue) { | ||
if (this._queue && this._queue._tileLayers && this._queue._tileLayers.indexOf(m_this) >= 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some idea why this is necessary but wondering if you could provide some explanations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a needed
function that determines if a tile is still needed. A tile is needed if it is needed by at least one layer that is using it. The _tileLayers
array is just a way to make sure we can enumerate the layers that are sharing the queue, and walk through the layers and ask if any layer needs a tile. Setting the queue (or exiting the layer) needs to maintain the book keeping for this list of layers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add that as a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that makes sense. So in the next line why are we setting this index to 1? The tileLayer is already has this queue before but the index may have been zero or above zero. Just wondering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not. We are removing the layer from the old queue's _tileLayers list it was part of. The splice(index, 1) says remove 1 value at its current location. We then push in on the new queue's _tileLayers list at the end of the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thanks for reminding the function execution, okay that makes sense.
🎉 This PR is included in version 1.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Although you could sort of share the fetch queue between tile layers, it wouldn't really share properly without a custom needed function. This explicitly supports sharing a fetch queue between tile layers.
This allows, for instance, multiple layers that access the same server to have a single fetch queue so that the number of requests against the server is limited (usually to 6) rather than that number multiplied by the number of layers.
This also adds an additional reference parameter to tile labels which prevents there from being a tile string collision between layers.
The multiframe tutorial now uses this.