]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/fs/rock/RockIoState.h
1 #ifndef SQUID_FS_ROCK_IO_STATE_H
2 #define SQUID_FS_ROCK_IO_STATE_H
4 #include "fs/rock/RockSwapDir.h"
16 class IoState
: public ::StoreIOState
19 typedef RefCount
<IoState
> Pointer
;
21 IoState(Rock::SwapDir::Pointer
&aDir
, StoreEntry
*e
, StoreIOState::STFNCB
*cbFile
, StoreIOState::STIOCB
*cbIo
, void *data
);
24 void file(const RefCount
<DiskFile
> &aFile
);
27 virtual void read_(char *buf
, size_t size
, off_t offset
, STRCB
* callback
, void *callback_data
);
28 virtual bool write(char const *buf
, size_t size
, off_t offset
, FREE
* free_func
);
29 virtual void close(int how
);
31 /// whether we are still waiting for the I/O results (i.e., not closed)
32 bool stillWaiting() const { return theFile
!= NULL
; }
34 /// forwards read data to the reader that initiated this I/O
35 void callReaderBack(const char *buf
, int rlen
);
37 /// called by SwapDir::writeCompleted() after the last write and on error
38 void finishedWriting(const int errFlag
);
40 MEMPROXY_CLASS(IoState
);
42 /* one and only one of these will be set and locked; access via *Anchor() */
43 const Ipc::StoreMapAnchor
*readableAnchor_
; ///< starting point for reading
44 Ipc::StoreMapAnchor
*writeableAnchor_
; ///< starting point for writing
46 SlotId sidCurrent
; ///< ID of the db slot currently being read or written
49 const Ipc::StoreMapAnchor
&readAnchor() const;
50 Ipc::StoreMapAnchor
&writeAnchor();
51 const Ipc::StoreMapSlice
¤tReadableSlice() const;
53 void tryWrite(char const *buf
, size_t size
, off_t offset
);
54 size_t writeToBuffer(char const *buf
, size_t size
);
55 void writeToDisk(const SlotId nextSlot
);
56 void writeBufToDisk(const SlotId nextSlot
, const bool eof
);
57 SlotId
reserveSlotForWriting();
59 void callBack(int errflag
);
61 Rock::SwapDir::Pointer dir
; ///< swap dir that initiated I/O
62 const size_t slotSize
; ///< db cell size
63 int64_t objOffset
; ///< object offset for current db slot
65 RefCount
<DiskFile
> theFile
; // "file" responsible for this I/O
66 MemBlob theBuf
; // use for write content accumulation only
69 MEMPROXY_CLASS_INLINE(IoState
);
73 #endif /* SQUID_FS_ROCK_IO_STATE_H */