Commit 890384bb authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 86cf093c
......@@ -160,6 +160,7 @@ type storage struct {
// XXX LastTid - report only LastTid for which cache is ready?
// or driver.LastTid(), then wait cache is ready?
// Load implements Loader.
func (s *storage) Load(ctx context.Context, xid Xid) (*mem.Buf, Tid, error) {
// XXX here: offload xid validation from cache and driver ?
// XXX here: offload wrapping err -> OpError{"load", err} ?
......@@ -170,6 +171,7 @@ func (s *storage) Load(ctx context.Context, xid Xid) (*mem.Buf, Tid, error) {
}
}
// Prefetch implements Prefetcher.
func (s *storage) Prefetch(ctx context.Context, xid Xid) {
if s.l1cache != nil {
s.l1cache.Prefetch(ctx, xid)
......@@ -202,8 +204,8 @@ func (s *storage) watcher() {
// also served - not to get stuck and support clients who do DelWatch
// and no longer receive from their watchq. However we cannot register
// added watchq immediately, because it is undefined whether or not
// we'll see it while iterating watchTab. So we queue what was added
// and flush it on the beginning of each cycle.
// we'll see it while iterating watchTab map. So we queue what was
// added and flush it to watchTab on the beginning of each cycle.
var addq map[chan<- Event]struct{}
addqFlush := func() {
for watchq := range addq {
......@@ -211,7 +213,7 @@ func (s *storage) watcher() {
}
addq = make(map[chan<- Event]struct{})
}
handleReq := func(req watchRequest) {
serveReq := func(req watchRequest) {
switch req.op {
case addWatch:
addq[req.watchq] = struct{}{}
......@@ -248,7 +250,7 @@ func (s *storage) watcher() {
select {
case req := <-s.watchReq:
handleReq(req)
serveReq(req)
case event, ok := <-s.drvWatchq:
if !ok {
......@@ -280,7 +282,7 @@ func (s *storage) watcher() {
for watchq := range s.watchTab {
select {
case req := <-s.watchReq:
handleReq(req)
serveReq(req)
case watchq <- event:
// ok
......@@ -292,7 +294,7 @@ func (s *storage) watcher() {
// AddWatch implements Watcher.
func (s *storage) AddWatch(watchq chan<- Event) (at0 Tid) {
// XXX when already Closed?
// XXX when already Closed? -> `go watchq <- .downErr + close(watchq)`
ack := make(chan Tid)
s.watchReq <- watchRequest{addWatch, ack, watchq}
return <-ack
......@@ -300,7 +302,7 @@ func (s *storage) AddWatch(watchq chan<- Event) (at0 Tid) {
// DelWatch implements Watcher.
func (s *storage) DelWatch(watchq chan<- Event) {
// XXX when already Closed?
// XXX when already Closed? -> noop
ack := make(chan Tid)
s.watchReq <- watchRequest{delWatch, ack, watchq}
<-ack
......
......@@ -441,7 +441,7 @@ type Event interface {
func (_ *EventError) event() {}
func (_ *EventCommit) event() {}
// EventError is event descrbing an error observed by watcher.
// EventError is event describing an error observed by watcher.
type EventError struct {
Err error
}
......@@ -467,7 +467,7 @@ type Watcher interface {
// sent, where at₀ is database head that was current when AddWatch call
// was made.
//
// Once registered, watchq must be read untill it is closed or until
// Once registered, watchq must be read until it is closed or until
// DelWatch call. Not doing so will stuck whole storage.
//
// Registered watchq are closed when the database storage is closed.
......@@ -478,7 +478,7 @@ type Watcher interface {
// DelWatch unregisters watchq from being notified of database changes.
//
// After DelWatch call completes, no new events will be sent to watchq.
// It is safe to call DelWatch without sumultaneously reading watchq.
// It is safe to call DelWatch without simultaneously reading watchq.
// In particular the following example is valid:
//
// at0 := stor.AddWatch(watchq)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment