Article Preview
Buy Now
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):
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.