louiscad
05/04/2018, 2:00 PMcancel()
methods in Channel
and Job
be optimized to not allocate a new CancellationException
when the channel is already closed or the job is already cancelled or completed?Vsevolod Tolstopyatov [JB]
05/04/2018, 2:45 PMClosed<*>
instance which can be avoided).
Job may allocate exception sometimes after being closed (depends on cancellation mode of implementation), in development
branch such exceptions are stacktraceless.louiscad
05/05/2018, 1:58 PMconsume { … }
more efficientVsevolod Tolstopyatov [JB]
05/06/2018, 7:51 PMconsume
pattern, but maybe it doesn’t for `Job`: each such check slows down first call to cancel
, but speeds up next ones. And jobs are frequently cancelled once, but rarely are cancelled multiple timesVsevolod Tolstopyatov [JB]
05/06/2018, 7:52 PMlouiscad
05/07/2018, 7:01 AMJob
, I guess calling cancel()
on the channel will cancel the associated Job
, so both cancel()
implementations need to be optimized if the goal is to optimize for consume
, right?
BTW, would checking for isCompleted
really slow down the first call to cancel
in a significant way, especially when measured against the cost of the allocation of the Closed<*>
instance plus the stacktrace filling?Vsevolod Tolstopyatov [JB]
05/07/2018, 8:13 AMso bothDepends on the wayimplementations need to be optimized, right?cancel()
Job
will be integrated into Channel
. Probably optimizing a channel is enough.
would checking forI doubt it, but it worth checking as part of the optimization.really slow down the first call toisCompleted
in a significant waycancel
louiscad
05/08/2018, 8:01 AMJob.cancel
too, then