using-worker-threads-with-konduktiva

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
using-worker-threads-with-konduktiva [2024/01/04 05:36] steve.wangusing-worker-threads-with-konduktiva [2024/03/20 18:36] (current) steve.wang
Line 3: Line 3:
 **Overview: ** Sometimes running too many actions in the same nodejs thread can cause Konduktiva sequencing to be delayed because of the heavy load on the system and the single threaded nature of nodejs. To avoid this issue, we can create other threads and run heavy actions there. Reading the [[https://nodejs.org/api/worker_threads.html#worker-threads|documentation about nodejs workers]] for about 5 minutes or enough to understand the basic function of nodejs workers is recommended. **Overview: ** Sometimes running too many actions in the same nodejs thread can cause Konduktiva sequencing to be delayed because of the heavy load on the system and the single threaded nature of nodejs. To avoid this issue, we can create other threads and run heavy actions there. Reading the [[https://nodejs.org/api/worker_threads.html#worker-threads|documentation about nodejs workers]] for about 5 minutes or enough to understand the basic function of nodejs workers is recommended.
  
-**Things To Note:** This tutorial assumes you have already installed Konduktiva successfully using the [[https://github.com/renickbell/konduktiva|Konduktiva installation]] instructions and have read through and understood the [[:first_steps|first steps tutorial]]. The tutorial also assumes that you have imported Konduktiva to the //K// variable and assigned any of the example MusicalEnvironments to the //e// variable. +**Things To Note:** This tutorial assumes you have already installed Konduktiva successfully using the [[https://github.com/renickbell/konduktiva|Konduktiva installation]] instructions and have read through and understood the [[:first_steps|first steps tutorial]]. The tutorial also assumes 2 things. One, Konduktiva has been assigned to the //K// variable. Two, user created a Musical Environment using the //setUpMusicalEnvironment// function using //K.defaultConfigurationObject// as the first argument and //'exampleMidiPlayer'// as the third argument then, assigned the output to the //e// variable. 
 +<code javascript> 
 +const K = require('konduktiva'
 +let e = K.setUpMusicalEnvironment(K.defaultConfigurationObject,4,'exampleMidiPlayer', K.exampleMusicalEnvironmentsExtraConfig) 
 +</code>
 ===== giveWorkerWork ===== ===== giveWorkerWork =====
  
Line 36: Line 39:
 let testResult = await K.giveWorkerWork(requireTest) let testResult = await K.giveWorkerWork(requireTest)
 </code> </code>
 +
 +Here is an example of adding the information given by workers to the musical environment. In this example, I will user workers to create a QuantizedMap for filterMap. The contents will be the same as chromatic.
 +<code javascript>
 +let QWorkerCode = `let {QuantizedMap} = require('konduktiva'); let A = require("array-toolkit"); returnToParent(new QuantizedMap(10, A.buildArray(12, x => {return x}), A.buildArray(10, x => {return x})))`
 +let QResults = await K.giveWorkerWork(QWorkerCode)
 +e.modeFilters.sameAsChromatic = new K.QuantizedMap(QResults.keyspan, QResults.keys, QResults.values)
 +</code>
 +
 +
  • using-worker-threads-with-konduktiva.1704375406.txt.gz
  • Last modified: 2024/01/04 05:36
  • by steve.wang