@@ -28,6 +28,7 @@ import {
28
28
} from '@jupyterlab/observables' ;
29
29
30
30
import { IOutputAreaModel , OutputAreaModel } from '@jupyterlab/outputarea' ;
31
+ const globalModelDBMutex = models . createMutex ( ) ;
31
32
32
33
/**
33
34
* The definition of a model object for a cell.
@@ -308,7 +309,7 @@ export class CellModel extends CodeEditor.Model implements ICellModel {
308
309
event : IObservableJSON . IChangedArgs
309
310
) : void {
310
311
const metadata = this . sharedModel . getMetadata ( ) ;
311
- this . _modelDBMutex ( ( ) => {
312
+ globalModelDBMutex ( ( ) => {
312
313
switch ( event . type ) {
313
314
case 'add' :
314
315
this . _changeCellMetadata ( metadata , event ) ;
@@ -377,7 +378,7 @@ export class CellModel extends CodeEditor.Model implements ICellModel {
377
378
change : models . CellChange < models . ISharedBaseCellMetadata >
378
379
) : void {
379
380
super . _onSharedModelChanged ( sender , change ) ;
380
- this . _modelDBMutex ( ( ) => {
381
+ globalModelDBMutex ( ( ) => {
381
382
if ( change . metadataChange ) {
382
383
const newValue = change . metadataChange
383
384
?. newValue as models . ISharedBaseCellMetadata ;
@@ -420,11 +421,6 @@ export class CellModel extends CodeEditor.Model implements ICellModel {
420
421
protected onGenericChange ( ) : void {
421
422
this . contentChanged . emit ( void 0 ) ;
422
423
}
423
-
424
- /**
425
- * A mutex to update the shared model.
426
- */
427
- protected readonly _modelDBMutex = models . createMutex ( ) ;
428
424
sharedModel : models . ISharedCell ;
429
425
}
430
426
@@ -629,7 +625,7 @@ export class CodeCellModel extends CellModel implements ICodeCellModel {
629
625
630
626
executionCount . changed . connect ( this . _onExecutionCountChanged , this ) ;
631
627
632
- this . _modelDBMutex ( ( ) => {
628
+ globalModelDBMutex ( ( ) => {
633
629
const sharedCell = this . sharedModel as models . ISharedCodeCell ;
634
630
sharedCell . setOutputs ( outputs ) ;
635
631
} ) ;
@@ -790,7 +786,7 @@ export class CodeCellModel extends CellModel implements ICodeCellModel {
790
786
event : IOutputAreaModel . ChangedArgs
791
787
) : void {
792
788
const codeCell = this . sharedModel as models . YCodeCell ;
793
- this . _modelDBMutex ( ( ) => {
789
+ globalModelDBMutex ( ( ) => {
794
790
switch ( event . type ) {
795
791
case 'add' : {
796
792
const outputs = event . newValues . map ( output => output . toJSON ( ) ) ;
@@ -842,7 +838,7 @@ export class CodeCellModel extends CellModel implements ICodeCellModel {
842
838
change : models . CellChange < models . ISharedBaseCellMetadata >
843
839
) : void {
844
840
super . _onSharedModelChanged ( sender , change ) ;
845
- this . _modelDBMutex ( ( ) => {
841
+ globalModelDBMutex ( ( ) => {
846
842
if ( change . outputsChange ) {
847
843
this . clearExecution ( ) ;
848
844
sender . getOutputs ( ) . forEach ( output => this . _outputs . add ( output ) ) ;
@@ -864,7 +860,7 @@ export class CodeCellModel extends CellModel implements ICodeCellModel {
864
860
args : ObservableValue . IChangedArgs
865
861
) : void {
866
862
const codeCell = this . sharedModel as models . YCodeCell ;
867
- this . _modelDBMutex ( ( ) => {
863
+ globalModelDBMutex ( ( ) => {
868
864
codeCell . execution_count = args . newValue
869
865
? ( args . newValue as number )
870
866
: null ;
0 commit comments