mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-08 11:56:36 +00:00
Run the Board.List
requests sequentially.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
7494beca33
commit
19f058cb7f
@ -1,3 +1,4 @@
|
|||||||
|
import * as PQueue from 'p-queue';
|
||||||
import { injectable, inject } from 'inversify';
|
import { injectable, inject } from 'inversify';
|
||||||
import { BoardsService, AttachedSerialBoard, BoardPackage, Board, AttachedNetworkBoard } from '../common/protocol/boards-service';
|
import { BoardsService, AttachedSerialBoard, BoardPackage, Board, AttachedNetworkBoard } from '../common/protocol/boards-service';
|
||||||
import { PlatformSearchReq, PlatformSearchResp, PlatformInstallReq, PlatformInstallResp, PlatformListReq, PlatformListResp } from './cli-protocol/commands/core_pb';
|
import { PlatformSearchReq, PlatformSearchResp, PlatformInstallReq, PlatformInstallResp, PlatformListReq, PlatformListResp } from './cli-protocol/commands/core_pb';
|
||||||
@ -15,15 +16,19 @@ export class BoardsServiceImpl implements BoardsService {
|
|||||||
protected readonly toolOutputService: ToolOutputServiceServer;
|
protected readonly toolOutputService: ToolOutputServiceServer;
|
||||||
|
|
||||||
protected selectedBoard: Board | undefined;
|
protected selectedBoard: Board | undefined;
|
||||||
|
protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
|
||||||
|
|
||||||
public async getAttachedBoards(): Promise<{ boards: Board[] }> {
|
public async getAttachedBoards(): Promise<{ boards: Board[] }> {
|
||||||
|
return this.queue.add(() => {
|
||||||
|
return new Promise<{ boards: Board[] }>(async resolve => {
|
||||||
const coreClient = await this.coreClientProvider.getClient();
|
const coreClient = await this.coreClientProvider.getClient();
|
||||||
const boards: Board[] = [];
|
const boards: Board[] = [];
|
||||||
if (!coreClient) {
|
if (!coreClient) {
|
||||||
return { boards };
|
resolve({ boards });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const { client, instance } = coreClient;
|
|
||||||
|
|
||||||
|
const { client, instance } = coreClient;
|
||||||
const req = new BoardListReq();
|
const req = new BoardListReq();
|
||||||
req.setInstance(instance);
|
req.setInstance(instance);
|
||||||
const resp = await new Promise<BoardListResp>((resolve, reject) => client.boardList(req, (err, resp) => (!!err ? reject : resolve)(!!err ? err : resp)));
|
const resp = await new Promise<BoardListResp>((resolve, reject) => client.boardList(req, (err, resp) => (!!err ? reject : resolve)(!!err ? err : resp)));
|
||||||
@ -50,7 +55,9 @@ export class BoardsServiceImpl implements BoardsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { boards };
|
resolve({boards});
|
||||||
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectBoard(board: Board): Promise<void> {
|
async selectBoard(board: Board): Promise<void> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user