mirror of
https://github.com/peco/peco.git
synced 2026-09-10 07:16:29 -04:00
... by punting the problem when the input is an infinite stream. This commit fixes the blocking, but the subsequent queries don't seem to be properly running refs #494
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package hub
|
|
|
|
import "sync"
|
|
|
|
// Hub acts as the messaging hub between components -- that is,
|
|
// it controls how the communication that goes through channels
|
|
// are handled.
|
|
type Hub struct {
|
|
isSync bool
|
|
mutex sync.Mutex
|
|
queryCh chan Payload
|
|
drawCh chan Payload
|
|
statusMsgCh chan Payload
|
|
pagingCh chan Payload
|
|
}
|
|
|
|
// Payload is a wrapper around the actual request value that needs
|
|
// to be passed. It contains an optional channel field which can
|
|
// be filled to force synchronous communication between the
|
|
// sender and receiver
|
|
type Payload interface {
|
|
// Batch returns true if this payload is part of a batch operation.
|
|
Batch() bool
|
|
|
|
// Data allows you to retrieve the data that's embedded in the payload.
|
|
Data() interface{}
|
|
|
|
// Done is called when the payload has been processed. There are cases
|
|
// where the payload processing is expected to be synchronized with the
|
|
// caller, and this method signals the caller that it is safe to proceed
|
|
// to whatever next action it was expecting
|
|
Done()
|
|
}
|
|
|
|
type payload struct {
|
|
batch bool
|
|
data interface{}
|
|
done chan struct{}
|
|
}
|