Skip to content

How do I register a function in the idle loop that pre-parses all the sources files under a specific directory #400

@nordlow

Description

@nordlow

The source file scanning under a source directory of a project using serve-d takes too long to complete interactively so it needs to be split up into parts where after each source file being parses the parallelMain loop needs to react to messages. I presume a fiber that yields after each source file parsing is completed. I see there is parallelMain and spawnFiber but I can't find any usage example of spawnFiber.

I see

	spawnFiber("Run didSave processors", {
		auto projectUri = workspace(params.textDocument.uri).folder.uri;

		auto project = &projectTests.require(projectUri, UnittestProject(projectUri));
		rescanFile(*project, params.textDocument);

		rpc.notifyMethod("coded/pushProjectTests", *project);
	}, requiredLibdparsePageCount * 2);

but I can't find any calls to yield in rescanFile.

Does the delegate passed to spawnFiber need to care about it being interrupted? If so, how does it suspend (yield) itself and how does it signal to itself when file scanning is done? Do I simply Fiber.yield at the end of the foreach-source-file scope?

It would be very nice if serve-d contained such a code example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions