Squid Web Cache master
Loading...
Searching...
No Matches
DiskThreadsDiskFile.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9/* DEBUG: section 79 Disk IO Routines */
10
11#ifndef SQUID_SRC_DISKIO_DISKTHREADS_DISKTHREADSDISKFILE_H
12#define SQUID_SRC_DISKIO_DISKTHREADS_DISKTHREADSDISKFILE_H
13
14#include "cbdata.h"
15#include "DiskIO/DiskFile.h"
16#include "DiskThreads.h"
17#include "typedefs.h" //for DWCB
18
20{
22
23public:
24 DiskThreadsDiskFile(char const *path);
25 ~DiskThreadsDiskFile() override;
26 void open(int flags, mode_t mode, RefCount<IORequestor> callback) override;
27 void create(int flags, mode_t mode, RefCount<IORequestor> callback) override;
28 void read(ReadRequest *) override;
29 void write(WriteRequest *) override;
30 void close() override;
31 bool error() const override;
32 int getFD() const override { return fd;}
33
34 bool canRead() const override;
35 bool canWrite() const override;
36 bool ioInProgress() const override;
37
38private:
39#if ASYNC_READ
40
41 static AIOCB ReadDone;
42#else
43
44 static DRCB ReadDone;
45#endif
46#if ASYNC_WRITE
47
48 static AIOCB WriteDone;
49#else
50
52#endif
53
54 int fd = -1;
55 bool errorOccured = false;
56 char const *path_ = nullptr;
57 size_t inProgressIOs = 0;
59 void openDone(int fd, const char *buf, int aio_return, int aio_errno);
61 void doClose();
62
63 void readDone(int fd, const char *buf, int len, int errflag, const RefCount<ReadRequest> &request);
64 void writeDone(int fd, int errflag, size_t len, RefCount<WriteRequest> request);
65};
66
67#include "DiskIO/ReadRequest.h"
68
69template <class RT>
80
81template <class RT>
83IOResult(RefCount<RT> aRequest, RefCount<DiskThreadsDiskFile> aFile) { return IoResult<RT>(aFile, aRequest);}
84
85#endif /* SQUID_SRC_DISKIO_DISKTHREADS_DISKTHREADSDISKFILE_H */
86
IoResult< RT > IOResult(RefCount< RT > aRequest, RefCount< DiskThreadsDiskFile > aFile)
void AIOCB(int fd, void *cbdata, const char *buf, int aio_return, int aio_errno)
Definition DiskThreads.h:57
void openDone(int fd, const char *buf, int aio_return, int aio_errno)
bool ioInProgress() const override
void create(int flags, mode_t mode, RefCount< IORequestor > callback) override
int getFD() const override
void writeDone(int fd, int errflag, size_t len, RefCount< WriteRequest > request)
void open(int flags, mode_t mode, RefCount< IORequestor > callback) override
bool canRead() const override
void readDone(int fd, const char *buf, int len, int errflag, const RefCount< ReadRequest > &request)
bool error() const override
CBDATA_CLASS(DiskThreadsDiskFile)
bool canWrite() const override
RefCount< IORequestor > ioRequestor
void write(WriteRequest *) override
void read(ReadRequest *) override
CBDATA_CLASS(IoResult)
RefCount< DiskThreadsDiskFile > file
IoResult(RefCount< DiskThreadsDiskFile > aFile, RefCount< RT > aRequest)
RefCount< RT > request
void DRCB(int, const char *buf, int size, int errflag, void *data)
Definition typedefs.h:16
void DWCB(int, int, size_t, void *)
Definition typedefs.h:18
unsigned short mode_t
Definition types.h:129