1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- const WorkerState = require('./WorkerState');
- const ssNormal = 'normal';
- const ssDbLoading = 'db_loading';
- let instance = null;
- class WebWorker {
- constructor(config) {
- if (!instance) {
- this.config = config;
- this.workerState = new WorkerState();
-
- this.wState = this.workerState.getControl('server_state');
- this.myState = '';
- this.loadOrCreateDb();
- instance = this;
- }
- return instance;
- }
- checkMyState() {
- if (this.myState != ssNormal)
- throw new Error('server_busy');
- }
- setMyState(newState) {
- this.myState = newState;
- this.wState.set({state: newState});
- }
- async loadOrCreateDb() {
- this.setMyState(ssDbLoading);
- try {
-
- } catch (e) {
-
- } finally {
- this.setMyState(ssNormal);
- }
- }
- }
- module.exports = WebWorker;
|