Skip to content

Fix threading issue of Atlas.FallbackStack, and introduce overloads with fallback parameter#1089

Open
Saplonily wants to merge 3 commits intoEverestAPI:devfrom
Saplonily:fallback-stack-fix
Open

Fix threading issue of Atlas.FallbackStack, and introduce overloads with fallback parameter#1089
Saplonily wants to merge 3 commits intoEverestAPI:devfrom
Saplonily:fallback-stack-fix

Conversation

@Saplonily
Copy link
Contributor

This pr changes the Atlas.FallbackStack implementation into ThreadLocal<T>, since the expected usage of it is that, pushing a fallback, get something from Atlas in this context, and then pop it, which make sense to make it thread local.
If we're using ConcurrentStack, then one thread may get a fallback that pushed from another thread, which is not expected.


There's an optional commit that marks stack operation methods as obsolete, and add some overloads that accept a fallback parameter, because this is a much easier way to reach that.

namespace Monocle;

public class Atlas
{
+   [Obsolete(MessageFallbackStackObsolete)]
    public void PushFallback(MTexture fallback)

+   [Obsolete(MessageFallbackStackObsolete)]
    public MTexture PopFallback()

+   public MTexture GetDefaultFallback();
+   public MTexture GetAtlasSubtexturesAt(string key, int index, MTexture fallback)
+   public List<MTexture> GetAtlasSubtextures(string key, MTexture fallback)
+   public MTexture GetWithFallback(string id, MTexture fallback) 
}

@maddie480-bot maddie480-bot added the 1: review needed This PR needs 2 approvals to be merged (bot-managed) label Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1: review needed This PR needs 2 approvals to be merged (bot-managed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants