Skip to content

Implement barrier for phases #10

@marcomicera

Description

@marcomicera

Right now, the master waits for all the modules of a given phase using a counter and go channels:

// Waiting for modules' responses.
// Apparently, we cannot wait for multiple messages belonging to different queues.
// However, it makes sense for Quartermaster to wait only for messages belonging
// to the current phase (i.e., builder, analysis, report).
// The master consumes messages following that order.
allModulesHaveResponded := make(chan bool)
remainingModules := len(modulesToWakeUp)
consumeModuleResponse(ch, &builderResponseQueue, allModulesHaveResponded, &remainingModules)
consumeModuleResponse(ch, &analyzerResponseQueue, allModulesHaveResponded, &remainingModules)
consumeModuleResponse(ch, &reporterResponseQueue, allModulesHaveResponded, &remainingModules)
<-allModulesHaveResponded

The counter is being decremented in the module response callback:

*remainingModules -= 1
if *remainingModules == 0 {
finalModuleHasResponded <- true
}

Is there a better way to handle this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions