Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 19.1

FEATURE

Working with Workers

Using multiple cores with Workers

Issue: 19.1 (January/February 2021)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer, but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 40,285
Starting Page Number: 25
Article Number: 19104
Resource File(s):

Download Icon project19104.zip Updated: 2021-01-04 09:44:02

Related Link(s): None

Excerpt of article text...

Making your program work faster has always been fascinating to me. Usually this is done via optimization, or a better algorithm. It's wild that just changing technique can speed things up. That's rare in the real world—you can't make your lawnmower cut your grass faster just by tweaking some settings!

But, sometimes even in computing, you just need more power. Since modern computers all include processors with multiple cores (essentially multiple processors in one chip), you often actually have more power available—the trick is accessing it.

Working with multiple cores, however, is complicated on multiple levels. Xojo itself hasn't supported the feature natively—everything in your app runs on a single core—and it can be tough to break a computing problem down into separate parts that can be acted upon simultaneously. (We've written about these difficulties in past xDev issues: see the "Multicore Processing" series in 13.6, 14.1, 14.3, and 14.4.)

The traditional approach in Xojo has been to create console apps that can each work on part of the problem and can each run on their own core. The tough part has been managing all that and communicating back and forth between the console app(s) and your main program.

Now with Xojo 2020 Release 2, that's in the past. Xojo has introduced Workers, a special kind of class that handles all the console app management for you. You basically add a Worker to your project, fill in code on a few events to tell the Worker what to do, and when you run your app the console worker-apps are created, each doing their part of the asked task, and the task is done faster than if run on only one core.

At least that's the theory.

...End of Excerpt. Please purchase the magazine to read the full article.