DiskThreadsDiskFile.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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_DISKTHREADSDISKFILE_H
12 #define SQUID_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 
23 public:
24  DiskThreadsDiskFile(char const *path);
26  virtual void open(int flags, mode_t mode, RefCount<IORequestor> callback);
27  virtual void create(int flags, mode_t mode, RefCount<IORequestor> callback);
28  virtual void read(ReadRequest *);
29  virtual void write(WriteRequest *);
30  virtual void close();
31  virtual bool error() const;
32  virtual int getFD() const { return fd;}
33 
34  virtual bool canRead() const;
35  virtual bool canWrite() const;
36  virtual bool ioInProgress() const;
37 
38 private:
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 
51  static DWCB WriteDone;
52 #endif
53 
54  int fd = -1;
55  bool errorOccured = false;
56  char const *path_ = nullptr;
57  size_t inProgressIOs = 0;
58  static AIOCB OpenDone;
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, RefCount<ReadRequest> request);
64  void writeDone(int fd, int errflag, size_t len, RefCount<WriteRequest> request);
65 };
66 
67 #include "DiskIO/ReadRequest.h"
68 
69 template <class RT>
70 class IoResult
71 {
73 
74 public:
75  IoResult(RefCount<DiskThreadsDiskFile> aFile, RefCount<RT> aRequest) : file(aFile), request(aRequest) {}
76 
79 };
80 
81 template <class RT>
83 IOResult(RefCount<RT> aRequest, RefCount<DiskThreadsDiskFile> aFile) { return IoResult<RT>(aFile, aRequest);}
84 
85 #endif /* SQUID_DISKTHREADSDISKFILE_H */
86 
virtual void create(int flags, mode_t mode, RefCount< IORequestor > callback)
void const char HLPCB * callback
Definition: stub_helper.cc:16
IoResult< RT > IOResult(RefCount< RT > aRequest, RefCount< DiskThreadsDiskFile > aFile)
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
virtual bool error() const
void DWCB(int, int, size_t, void *)
Definition: typedefs.h:18
void readDone(int fd, const char *buf, int len, int errflag, RefCount< ReadRequest > request)
void openDone(int fd, const char *buf, int aio_return, int aio_errno)
RefCount< DiskThreadsDiskFile > file
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
virtual void write(WriteRequest *)
void DRCB(int, const char *buf, int size, int errflag, void *data)
Definition: typedefs.h:16
void const char * buf
Definition: stub_helper.cc:16
virtual bool ioInProgress() const
unsigned short mode_t
Definition: types.h:150
virtual void open(int flags, mode_t mode, RefCount< IORequestor > callback)
RefCount< RT > request
CBDATA_CLASS(IoResult)
void writeDone(int fd, int errflag, size_t len, RefCount< WriteRequest > request)
RefCount< IORequestor > ioRequestor
virtual bool canRead() const
virtual void read(ReadRequest *)
DiskThreadsDiskFile(char const *path)
void AIOCB(int fd, void *cbdata, const char *buf, int aio_return, int aio_errno)
Definition: DiskThreads.h:57
virtual int getFD() const
CBDATA_CLASS(DiskThreadsDiskFile)
virtual bool canWrite() const
IoResult(RefCount< DiskThreadsDiskFile > aFile, RefCount< RT > aRequest)

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors