Concurrency Architecture

@ibc @snnz That patch looks good to me. I can test it out in my dev environment tonight.

Thanks, let us know the results.

Not while pipeProducer = await remotePipeTransport!.produce(), but while pipeConsumer = await localPipeTransport!.consume() is in progress. Because if remotePipeTransport!.produce() adds its request before producer.resume does, everything is ok: pipeProducer is created, then comes the result of producer.resume from the worker.

I would suggest another idea. What if instead of POD structure for the data parameter of the channel.request there was an object with the method that performed deferred calculation of the actual data? Maybe as a variant. For example:

				pipeProducer = await remotePipeTransport!.produce({ deferred: () =>
					{
						id            : producer.id,
						kind          : pipeConsumer!.kind,
						rtpParameters : pipeConsumer!.rtpParameters,
						paused        : pipeConsumer!.producerPaused,
						appData       : producer.appData
					}});

Then in Channel.request:

					if (typeof data.deferred === 'function') data = data.deferred();

This way it will take into account the results of all previous requests.

We cannot change the API at this stage.

Well, this was just a suggestion. But in what way the API would have been involved? I thought the Channel class is only used for internal purposes.

P.S. Sorry, I forgot that the data is used in the transport.produce too. I withdraw the question.

@ibc I patched Router.ts and Router.js per your spec and can confirm it works for my non-sequenced test environment:

Pre-patch:

pipeToRouter()
  producer.paused == true

producer.resume()

pipeToRouter() complete

producer.paused == false
pipeConsumer.producerPaused == true
pipeConsumer.paused == false
pipeProducer.paused == **true** <-- **Original inconsistent result.**

Post-patch:

pipeToRouter()

producer.paused == true

producer.resume()
pipeToRouter() complete

producer.paused == false
pipeConsumer.producerPaused == false
pipeConsumer.paused == false
pipeProducer.paused == **false** <-- Expected.
1 Like

Thanks for confirming.