network chunk v2
This commit is contained in:
@@ -28,24 +28,18 @@ export class FileSharer {
|
||||
async start(): Promise<void> {
|
||||
setInterval(async () => {
|
||||
if (!this.isBusy) { // Check if the queue is already being processed
|
||||
this.isBusy = true; // Set busy flag to true before starting
|
||||
this.log("Start successfully. Processing the queue.");
|
||||
await this.processQueue(); // Process the queue at regular intervals
|
||||
this.log("Queue processing completed.");
|
||||
await this.processQueue();
|
||||
}
|
||||
}, 10000); // 10 seconds interval
|
||||
}
|
||||
|
||||
// Method to process the queue
|
||||
private async processQueue(): Promise<void> {
|
||||
if (this.isBusy) {
|
||||
this.log("Queue is already being processed. Skipping this interval.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.isBusy = true; // Set busy flag to true before starting
|
||||
|
||||
while (!this.queueManager.isEmpty()) {
|
||||
const task = this.queueManager.peek();
|
||||
this.log('trimiti fisier');
|
||||
|
||||
if (task) {
|
||||
this.log(`Processing task for file: ${task.path} to IP: ${task.ip}`);
|
||||
|
||||
Reference in New Issue
Block a user