A Thank You to Xojo for: Preemptive Threads

I finally have some time to take care of non-urgent things and thought I would use it to thank the Xojo team for the great work they did in implementing preemptive threads.

I am very impressed and grateful for how well preemptive threads work in their first iteration.
It is a great pleasure to gradually convert my main application to preemptive threads where it makes sense.

At the same time, while doing this work, I realize how well cooperative threads work in Xojo. Here and there, I switch cooperative threads to preemptive threads, only to find that the app’s UI already worked very well with cooperative threads.
But of course there are also many situations in which I was able to achieve a massive boost by using preemptive threads.

It’s amazing how much more professional Xojo suddenly feels. And it’s so much fun to squeeze every last bit of performance out of the code.

Thank you very much for the fantastic work, Xojo. Thank you! :pray:

35 Likes

I was thinking about posting much the same thing - I totally agree.

It’s been one of the biggest complaints about the Xojo architecture and one of my concerns for the longer term - especially as CPUs continue to move to many cores to gain performance.

There may be some bumps along the way but it seems like a very good start and I’m excited for the future!

4 Likes

By the way, in my most important program I use preemptive threads not for computationally intensive operations but for a higher response time.

We use this program to handle all of our daily work with our customers. We are an Internet provider. When a customer is loaded into my program, at first only the most important information is loaded and presented. This includes address details and Internet connections, for example. Other data such as phone numbers, invoices, contracts, etc. are only loaded when required. I am currently changing this behavior so that all relevant information is loaded immediately, but in preemptive threads. This means we can switch more quickly from the customer’s information that is loaded first to other areas/information.

The program is highly optimized and no one has ever complained about performance, but it is nice to see that my users enjoy the program more with each new release and that we save time every time. :smiling_face:

4 Likes

Yes! smoothing out the user experience is a great place for improvements.

I’m wondering if we should be creating a ‘promise’-style function that would make the UI easier to form.

We have a number of elements that take a little while to open/calculate. When we add them to the UI the whole thing can stutter for a moment. Clearly preemptive threads could help in this regard but that can make UI coding a lot more complicated.

In the web world, javascript and some web frameworks handle this using promises, allowing the UI to update with what’s already available - like adding an item to a list - and then updating the UI when more data arrives.

It would be nice to have such a capability in Xojo where we complete updates like adding a list item with what’s available, then launch a thread and have the updates flow into the UI easily when they’re ready. It gets complicated when you want to have an activity indicator that needs hiding, have the update event fire the right code and also handling errors or the user cancelling a process and moving on to something else. Promises give the current objects something to hang onto and manage to delay the fulfillment of everything thats needed.

Anyone dealt with such a thing in the Xojo realm?