Close will tell the workers to stop
()
| 289 | |
| 290 | // Close will tell the workers to stop |
| 291 | func (r *Handle) Close() error { |
| 292 | r.mu.Lock() |
| 293 | defer r.mu.Unlock() |
| 294 | if r.closed { |
| 295 | return errors.New("file already closed") |
| 296 | } |
| 297 | |
| 298 | close(r.preloadQueue) |
| 299 | r.closed = true |
| 300 | // wait for workers to complete their jobs before returning |
| 301 | r.workersWg.Wait() |
| 302 | r.memory.db.Flush() |
| 303 | |
| 304 | fs.Debugf(r, "cache reader closed %v", r.offset) |
| 305 | return nil |
| 306 | } |
| 307 | |
| 308 | // Seek will move the current offset based on whence and instruct the workers to move there too |
| 309 | func (r *Handle) Seek(offset int64, whence int) (int64, error) { |