]>
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 /// called by SwapDir::writeCompleted() after the last write and on error
35 void finishedWriting(const int errFlag
);
37 MEMPROXY_CLASS(IoState
);
39 /* one and only one of these will be set and locked; access via *Anchor() */
40 const Ipc::StoreMapAnchor
*readableAnchor_
; ///< starting point for reading
41 Ipc::StoreMapAnchor
*writeableAnchor_
; ///< starting point for writing
43 SlotId sidCurrent
; ///< ID of the db slot currently being read or written
46 const Ipc::StoreMapAnchor
&readAnchor() const;
47 Ipc::StoreMapAnchor
&writeAnchor();
48 const Ipc::StoreMapSlice
¤tReadableSlice() const;
50 void tryWrite(char const *buf
, size_t size
, off_t offset
);
51 size_t writeToBuffer(char const *buf
, size_t size
);
52 void writeToDisk(const SlotId nextSlot
);
53 SlotId
reserveSlotForWriting();
55 void callBack(int errflag
);
57 Rock::SwapDir::Pointer dir
; ///< swap dir that initiated I/O
58 const size_t slotSize
; ///< db cell size
59 int64_t objOffset
; ///< object offset for current db slot
61 RefCount
<DiskFile
> theFile
; // "file" responsible for this I/O
62 MemBlob theBuf
; // use for write content accumulation only
65 MEMPROXY_CLASS_INLINE(IoState
);
69 #endif /* SQUID_FS_ROCK_IO_STATE_H */