krähemann.com

Worker-threads to do tic-less parallelism

Worker threads are used to perform heavy load tasks that run completely asynchronous. This means they don't do any sync with the tree. You start worker threads like any other thread by calling void ags_thread_start(AgsThread*) or void ags_thread_stop(AgsThread*) to stop it.

The AgsWorkerThread overrides ::start of AgsThread class and won't do any synchronization. The worker implementation is responsible to delay computation by calling usleep() or nanosleep().

You can either connect to the ::do-poll signal or inherit of the AgsWorkerThread object. This requires to override ::do-poll.

Asynchronously destroy objects

AgsDestroyWorker is intended to unref or free objects asynchrously. Note the use of this worker for one certain instance, requires it to do it throughout with the worker for all unref calls. Else you would probably end in a data-race ending in accessing a freed instance. This can especially happen as using g_object_run_dispose().

The destroy function takes exactly one parameter like g_free() or g_object_unref(). To add an entry call ags_destroy_worker_add(). The first parameter is the worker, second the pointer to free/unref and third the destroy function.