(source, destination, value, transferList, memory)
| 98 | } |
| 99 | |
| 100 | function sendMessageToWorker(source, destination, value, transferList, memory) { |
| 101 | // We are on the main thread, we can directly process the message |
| 102 | if (destination === 0) { |
| 103 | receiveMessageFromWorker(source, value, memory); |
| 104 | return; |
| 105 | } |
| 106 | |
| 107 | // Search the port to the target thread |
| 108 | const port = threadsPorts.get(destination); |
| 109 | |
| 110 | if (!port) { |
| 111 | const status = new Int32Array(memory); |
| 112 | AtomicsStore(status, WORKER_MESSAGING_RESULT_INDEX, WORKER_MESSAGING_RESULT_NO_LISTENERS); |
| 113 | AtomicsStore(status, WORKER_MESSAGING_STATUS_INDEX, 1); |
| 114 | AtomicsNotify(status, WORKER_MESSAGING_STATUS_INDEX, 1); |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | port.postMessage( |
| 119 | { |
| 120 | type: messageTypes.RECEIVE_MESSAGE_FROM_WORKER, |
| 121 | source, |
| 122 | destination, |
| 123 | value, |
| 124 | memory, |
| 125 | }, |
| 126 | transferList, |
| 127 | ); |
| 128 | } |
| 129 | |
| 130 | function receiveMessageFromWorker(source, value, memory) { |
| 131 | let response = WORKER_MESSAGING_RESULT_NO_LISTENERS; |
no test coverage detected
searching dependent graphs…