3 /* The pull_list package manages a list of pull requests sent
8 pull_list.NewManager() creates and returns a pull_list.Manager. A
9 listener runs in a goroutine, waiting for new requests on its input
12 pull_list.SetList() assigns a new pull list to the manager. Any
13 existing list is discarded.
15 pull_list.GetList() reports the manager's current pull list.
17 pull_list.Close() shuts down the pull list manager.
20 type PullRequest struct {
26 setlist chan []PullRequest // input channel for setting new lists
27 getlist chan []PullRequest // output channel for getting existing list
30 // NewManager returns a new Manager object. It launches a goroutine that
31 // waits for pull requests.
33 func NewManager() *Manager {
35 make(chan []PullRequest),
36 make(chan []PullRequest),
42 // SetList sends a new list of pull requests to the manager goroutine.
43 // The manager will discard any outstanding pull list and begin
44 // working on the new list.
46 func (r *Manager) SetList(pr []PullRequest) {
50 // GetList reports the contents of the current pull list.
51 func (r *Manager) GetList() []PullRequest {
55 // Close shuts down the manager and terminates the goroutine, which
56 // completes any pull request in progress and abandons any pending
59 func (r *Manager) Close() {
63 // listen is run in a goroutine. It reads new pull lists from its
64 // input queue until the queue is closed.
65 func (r *Manager) listen() {
66 var current []PullRequest
69 case p, ok := <-r.setlist:
73 // The input channel is closed; time to shut down
77 case r.getlist <- current: