]> git.ipfire.org Git - thirdparty/squid.git/blob - src/DiskIO/DiskThreads/DiskThreadsDiskFile.h
Split out cbdata fully, it now is an optional include and no Init call is needed.
[thirdparty/squid.git] / src / DiskIO / DiskThreads / DiskThreadsDiskFile.h
1
2 /*
3 * $Id: DiskThreadsDiskFile.h,v 1.2 2006/08/21 00:50:45 robertc Exp $
4 *
5 * DEBUG: section 79 Disk IO Routines
6 * AUTHOR: Robert Collins
7 *
8 * SQUID Web Proxy Cache http://www.squid-cache.org/
9 * ----------------------------------------------------------
10 *
11 * Squid is the result of efforts by numerous individuals from
12 * the Internet community; see the CONTRIBUTORS file for full
13 * details. Many organizations have provided support for Squid's
14 * development; see the SPONSORS file for full details. Squid is
15 * Copyrighted (C) 2001 by the Regents of the University of
16 * California; see the COPYRIGHT file for full details. Squid
17 * incorporates software developed and/or copyrighted by other
18 * sources; see the CREDITS file for full details.
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
33 *
34 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
35 */
36
37 #ifndef SQUID_DISKTHREADSDISKFILE_H
38 #define SQUID_DISKTHREADSDISKFILE_H
39 #include "cbdata.h"
40 #include "DiskIO/DiskFile.h"
41 #include "DiskThreads.h"
42
43 class DiskThreadsDiskFile : public DiskFile
44 {
45
46 public:
47 void * operator new (size_t);
48 void operator delete (void *);
49 DiskThreadsDiskFile (char const *path, DiskThreadsIOStrategy *);
50 ~DiskThreadsDiskFile();
51 virtual void open (int, mode_t, RefCount<IORequestor>);
52 virtual void create (int, mode_t, RefCount<IORequestor>);
53 virtual void read(ReadRequest *);
54 virtual void write(WriteRequest *);
55 virtual void close ();
56 virtual bool error() const;
57 virtual int getFD() const { return fd;}
58
59 virtual bool canRead() const;
60 virtual bool canWrite() const;
61 virtual bool ioInProgress()const;
62
63 private:
64 #if ASYNC_READ
65
66 static AIOCB ReadDone;
67 #else
68
69 static DRCB ReadDone;
70 #endif
71 #if ASYNC_WRITE
72
73 static AIOCB WriteDone;
74 #else
75
76 static DWCB WriteDone;
77 #endif
78
79 int fd;
80 bool errorOccured;
81 char const *path_;
82 DiskThreadsIOStrategy *IO;
83 size_t inProgressIOs;
84 static AIOCB OpenDone;
85 void openDone(int fd, const char *buf, int aio_return, int aio_errno);
86 RefCount<IORequestor> ioRequestor;
87 CBDATA_CLASS(DiskThreadsDiskFile);
88 void doClose();
89
90 void readDone(int fd, const char *buf, int len, int errflag, RefCount<ReadRequest>);
91 void writeDone (int fd, int errflag, size_t len, RefCount<WriteRequest>);
92 };
93
94 #include "DiskIO/ReadRequest.h"
95
96 template <class RT>
97
98 class IoResult
99 {
100
101 public:
102 void * operator new (size_t);
103 void operator delete (void *);
104 IoResult(RefCount<DiskThreadsDiskFile> aFile, RefCount<RT> aRequest) : file(aFile), request(aRequest){}
105
106 RefCount<DiskThreadsDiskFile> file;
107 RefCount<RT> request;
108
109 private:
110 CBDATA_CLASS(IoResult);
111 };
112
113 template <class RT>
114 IoResult<RT>
115 IOResult(RefCount<RT> aRequest, RefCount<DiskThreadsDiskFile> aFile) { return IoResult<RT>(aFile, aRequest);}
116
117 #endif /* SQUID_DISKTHREADSDISKFILE_H */