Ver código fonte

ReferenceImageDatabase.add(): try again later if busy

customisations
alemart 11 meses atrás
pai
commit
c2cfa857b0

+ 3
- 2
src/trackers/image-tracker/reference-image-database.ts Ver arquivo

@@ -24,6 +24,7 @@ import Speedy from 'speedy-vision';
24 24
 import { SpeedyMedia } from 'speedy-vision/types/core/speedy-media';
25 25
 import { SpeedyPromise } from 'speedy-vision/types/core/speedy-promise';
26 26
 import { ReferenceImage } from './reference-image';
27
+import { Utils } from '../../utils/utils';
27 28
 import { IllegalArgumentError, IllegalOperationError } from '../../utils/errors';
28 29
 
29 30
 /** Default capacity of a Reference Image Database */
@@ -133,7 +134,7 @@ export class ReferenceImageDatabase implements Iterable<ReferenceImage>
133 134
         // handle multiple images as input
134 135
         if(referenceImages.length > 1) {
135 136
             const promises = referenceImages.map(image => this.add([ image ]));
136
-            return Speedy.Promise.all(promises).then(() => void(0));
137
+            return Utils.runInSequence(promises);
137 138
         }
138 139
 
139 140
         // handle a single image as input
@@ -145,7 +146,7 @@ export class ReferenceImageDatabase implements Iterable<ReferenceImage>
145 146
 
146 147
         // busy loading another image?
147 148
         if(this._busy)
148
-            throw new IllegalOperationError(`Can't add reference image to the database: we're busy loading another image`);
149
+            return Utils.wait(4).then(() => this.add(referenceImages)); // try again later
149 150
 
150 151
         // reached full capacity?
151 152
         if(this.count >= this.capacity)

Carregando…
Cancelar
Salvar