sdboyer / gogl

A graph library in Go
MIT License
77 stars 13 forks source link

Create a visitor pattern where communication happens through channels #20

Open sdboyer opened 10 years ago

sdboyer commented 10 years ago

Visitors should, as a general rule, be fired off as separate goroutines and receive updates from the traversal algorithm via a buffered channel. this will allow traversal to occur independent of processing.

alternatively, because this is still basically a traversal, it may be preferable to keep the traversal algorithm communicating with the visitor via function calls, but provide a reference/default/simple implementation of the visitor that creates such channels and does the communication there. in fact...that's probably the preferable route, because that means the base/interface-specified case is still as fast as possible, but a simple pattern is established whereby it can can be translated into channels (which is the pattern generally considered optimal for gogl).