Add a function to query thread status


there is a long ongoing problem in Xojo, that we see StackOverflowExceptions when a callback is coming on some thread not known to Xojo.

Three years ago I filled a feedback case: 53201 - StackOverflowChecking should work for non Xojo threads by doing nothing

An alternative may be to let the plugin know the thread is a Xojo thread.

I also requested 47037 - is xojo thread function for plugin SDK to have a function telling me whether it’s a Xojo thread.

I wonder if something like this could be done?
Or is there a trick to access what Xojo currenthread function would do in a plugin?

e.g. could REALGetCurrentThread or Thread_CurrentThread from the Xojo framework be called via plugin, so we could know if there is a Xojo thread object for the current thread.

But that call would need to not cause trouble if called at any time and maybe not lock any object.
→ make safe to call in parallel to whatever other code in Xojo runs.

Or if there would be a function to get Thread Local Storage index for Xojo and we could use OS functions to ask for the pointer for that index, we could check if there is nil or a ptr.

If Xojo stores internally the per thread data in a thread local storage, we could just check if there is something stored for the current thread.

As you know, we do not support or even suggest you call Xojo code from a non-Xojo thread.

We’d be open to adding this.

1 Like

My key is to know if some code is running within
1 main thread
2 some other xojo thread
3 some other OS thread

In case 3 I need to do extra work, while in first case I just call the event.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.