Joose.Gears: Adding support for workers in a self-hosting meta object system

Malte Ubl, who brought us xssinterface, has a new project that has Gears support.

Joose is a self-hosting meta object system for JavaScript inspired by the Perl Moose. Joose supports inheritance, traits, mixins, method wrappers and more.

Where Gears comes into the mix is through the Joose.Gears meta class which enables automatic delegation of methods to be executed as a Gears worker. If Gears is not present, the worker is executed in the main thread. The workers result will be sent to a method called "on".ucfirst($worker_name) if available:

Class("HardWork", {
meta: Joose.Gears,
has: {
data: {is: rw, init: {}}
methods: {
onDoWork: function (result) {
ok(result == 1001, "Gear Worker returns correct result")
workers: {
doWork: function (start) {
var counter = start;
for(var i = 0; i < 1000; i++) {
return counter

var hw = new HardWork();

You can take a peak at the innards to see another interesting use of Gears.