Documentation ¶
Overview ¶
The chmsg provides a data structure that helps to manage interprocess communications between Goroutines via channels.
The ipc pagage provides several objects which make managing inter processes communications easier. The ipc package is built on top of Go's channels. Within the package is a generic message which provides request and response support and a tickler object which allows an application to schedule periodic messages to be delivered on one or more channels.
Index ¶
Constants ¶
const (
FOREVER int = 0
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chmsg ¶
type Chmsg struct { Msg_type int // action requested Response_ch chan *Chmsg // channel to write this request back onto when done Response_data interface{} // what might be useful in addition to the state Req_data interface{} // necessary information to processes the request Requestor_data interface{} // private data meaningful only to the requestor and // necessary to process an asynch response to the message. State error // response state, nil == no error }
--------------------------------------------------------------------------------------
Defines a message. Request and response data pointers are used so that in the case where the requesting thread is not blocking on the response the request data will be available for response processing if needed. A third data field, requestor_data is another hook to assist with asynch response processing. This is assumed to point to a data object that is of no significance to the receiver of the message when the message is a request. It should be nil if the response channel is also nil. The struct allows the application to define how it is used, and does not really imply any meaning on the fields.
func (*Chmsg) Send_nbreq ¶
func (r *Chmsg) Send_nbreq(dest_ch chan *Chmsg, resp_ch chan *Chmsg, mtype int, data interface{}, pdata interface{})
Sends the message as a request to the indicated channel. The no-block flag is set which causes the message to be SILENTLY droped if the reciving channel is blocking.
func (*Chmsg) Send_req ¶
func (r *Chmsg) Send_req(dest_ch chan *Chmsg, resp_ch chan *Chmsg, mtype int, data interface{}, pdata interface{})
Send the message as a request oriented packet. Data is mapped to request data, while response data and state are set to nil. Pdata is the private requestor data.
type Tickler ¶
type Tickler struct {
// contains filtered or unexported fields
}
Manages the user's list of tickle spots.
func Mk_tickler ¶
Create a tickle manager that can handle up to max concurrent tickles. We'll cap tickles at 1024 and default to 100 if 0 passed in as max.
func (*Tickler) Add_spot ¶
func (t *Tickler) Add_spot(delay int64, ch chan *Chmsg, ttype int, data interface{}, count int) (id int, err error)
Adds something to the tickle list. Delay is the number of seconds between tickles and will be set to 1 if it is less than that. Data is any object (best if it's a pointer to something) that will be sent on each tickle request. The return is the 'id' of the tickle that can be used to drop it, and an error if we could not add the tickle spot.
Add is synchronous so concurrent goroutines which share a common tickler can safely add their tickle spots without worry of corruption.
Tickle spots should be added in increasing delay order, or the tickler should be stopped until all tickle spots have been added. This prevents a long tickle spot from becoming active and blocking shorter tickles until the first long tickle 'pops'.
func (*Tickler) Allow_to_block ¶
Allow the user to control blocking mode of all tickle spots.