diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
commit | ec05778d5718a7912e506764d443a78d6a6179e3 (patch) | |
tree | 78a9a01532180030c095acefc45763f07c14edb8 /src/stable/conduit.cpp | |
parent | b20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff) | |
download | libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2 libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip |
Converted tabs to spaces with tabconv.
Diffstat (limited to 'src/stable/conduit.cpp')
-rw-r--r-- | src/stable/conduit.cpp | 240 |
1 files changed, 120 insertions, 120 deletions
diff --git a/src/stable/conduit.cpp b/src/stable/conduit.cpp index 8f5eba5..4c2fda6 100644 --- a/src/stable/conduit.cpp +++ b/src/stable/conduit.cpp | |||
@@ -8,9 +8,9 @@ | |||
8 | #include "bu/conduit.h" | 8 | #include "bu/conduit.h" |
9 | 9 | ||
10 | Bu::Conduit::Conduit( int iBlockSize ) : | 10 | Bu::Conduit::Conduit( int iBlockSize ) : |
11 | qb( iBlockSize ), | 11 | qb( iBlockSize ), |
12 | bBlocking( true ), | 12 | bBlocking( true ), |
13 | bOpen( true ) | 13 | bOpen( true ) |
14 | { | 14 | { |
15 | } | 15 | } |
16 | 16 | ||
@@ -20,100 +20,100 @@ Bu::Conduit::~Conduit() | |||
20 | 20 | ||
21 | void Bu::Conduit::close() | 21 | void Bu::Conduit::close() |
22 | { | 22 | { |
23 | im.lock(); | 23 | im.lock(); |
24 | // qb.close(); | 24 | // qb.close(); |
25 | bOpen = false; | 25 | bOpen = false; |
26 | 26 | ||
27 | cBlock.signal(); | 27 | cBlock.signal(); |
28 | im.unlock(); | 28 | im.unlock(); |
29 | } | 29 | } |
30 | 30 | ||
31 | #include <stdio.h> | 31 | #include <stdio.h> |
32 | Bu::size Bu::Conduit::read( void *pBuf, Bu::size nBytes ) | 32 | Bu::size Bu::Conduit::read( void *pBuf, Bu::size nBytes ) |
33 | { | 33 | { |
34 | if( !isOpen() ) | 34 | if( !isOpen() ) |
35 | { | 35 | { |
36 | return 0; | 36 | return 0; |
37 | } | 37 | } |
38 | im.lock(); | 38 | im.lock(); |
39 | if( bBlocking ) | 39 | if( bBlocking ) |
40 | { | 40 | { |
41 | im.unlock(); | 41 | im.unlock(); |
42 | cBlock.lock(); | 42 | cBlock.lock(); |
43 | for(;;) | 43 | for(;;) |
44 | { | 44 | { |
45 | im.lock(); | 45 | im.lock(); |
46 | if( qb.getSize() == 0 && bOpen == false ) | 46 | if( qb.getSize() == 0 && bOpen == false ) |
47 | { | 47 | { |
48 | im.unlock(); | 48 | im.unlock(); |
49 | cBlock.unlock(); | 49 | cBlock.unlock(); |
50 | return 0; | 50 | return 0; |
51 | } | 51 | } |
52 | else if( qb.getSize() > 0 ) | 52 | else if( qb.getSize() > 0 ) |
53 | { | 53 | { |
54 | im.unlock(); | 54 | im.unlock(); |
55 | break; | 55 | break; |
56 | } | 56 | } |
57 | im.unlock(); | 57 | im.unlock(); |
58 | 58 | ||
59 | cBlock.wait(); | 59 | cBlock.wait(); |
60 | } | 60 | } |
61 | 61 | ||
62 | im.lock(); | 62 | im.lock(); |
63 | Bu::size iRet = qb.read( pBuf, nBytes ); | 63 | Bu::size iRet = qb.read( pBuf, nBytes ); |
64 | im.unlock(); | 64 | im.unlock(); |
65 | 65 | ||
66 | cBlock.unlock(); | 66 | cBlock.unlock(); |
67 | return iRet; | 67 | return iRet; |
68 | } | 68 | } |
69 | else | 69 | else |
70 | { | 70 | { |
71 | Bu::size iRet = qb.read( pBuf, nBytes ); | 71 | Bu::size iRet = qb.read( pBuf, nBytes ); |
72 | im.unlock(); | 72 | im.unlock(); |
73 | 73 | ||
74 | return iRet; | 74 | return iRet; |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | Bu::size Bu::Conduit::peek( void *pBuf, Bu::size nBytes ) | 78 | Bu::size Bu::Conduit::peek( void *pBuf, Bu::size nBytes ) |
79 | { | 79 | { |
80 | im.lock(); | 80 | im.lock(); |
81 | Bu::size iRet = qb.peek( pBuf, nBytes ); | 81 | Bu::size iRet = qb.peek( pBuf, nBytes ); |
82 | im.unlock(); | 82 | im.unlock(); |
83 | 83 | ||
84 | return iRet; | 84 | return iRet; |
85 | } | 85 | } |
86 | 86 | ||
87 | Bu::size Bu::Conduit::peek( void *pBuf, Bu::size nBytes, Bu::size nSkip ) | 87 | Bu::size Bu::Conduit::peek( void *pBuf, Bu::size nBytes, Bu::size nSkip ) |
88 | { | 88 | { |
89 | im.lock(); | 89 | im.lock(); |
90 | Bu::size iRet = qb.peek( pBuf, nBytes, nSkip ); | 90 | Bu::size iRet = qb.peek( pBuf, nBytes, nSkip ); |
91 | im.unlock(); | 91 | im.unlock(); |
92 | 92 | ||
93 | return iRet; | 93 | return iRet; |
94 | } | 94 | } |
95 | 95 | ||
96 | Bu::size Bu::Conduit::write( const void *pBuf, Bu::size nBytes ) | 96 | Bu::size Bu::Conduit::write( const void *pBuf, Bu::size nBytes ) |
97 | { | 97 | { |
98 | im.lock(); | 98 | im.lock(); |
99 | if( bOpen == false ) | 99 | if( bOpen == false ) |
100 | { | 100 | { |
101 | im.unlock(); | 101 | im.unlock(); |
102 | return 0; | 102 | return 0; |
103 | } | 103 | } |
104 | Bu::size sRet = qb.write( pBuf, nBytes ); | 104 | Bu::size sRet = qb.write( pBuf, nBytes ); |
105 | cBlock.signal(); | 105 | cBlock.signal(); |
106 | im.unlock(); | 106 | im.unlock(); |
107 | 107 | ||
108 | return sRet; | 108 | return sRet; |
109 | } | 109 | } |
110 | 110 | ||
111 | Bu::size Bu::Conduit::tell() | 111 | Bu::size Bu::Conduit::tell() |
112 | { | 112 | { |
113 | im.lock(); | 113 | im.lock(); |
114 | Bu::size sRet = qb.tell(); | 114 | Bu::size sRet = qb.tell(); |
115 | im.unlock(); | 115 | im.unlock(); |
116 | return sRet; | 116 | return sRet; |
117 | } | 117 | } |
118 | 118 | ||
119 | void Bu::Conduit::seek( Bu::size ) | 119 | void Bu::Conduit::seek( Bu::size ) |
@@ -130,18 +130,18 @@ void Bu::Conduit::setPosEnd( Bu::size ) | |||
130 | 130 | ||
131 | bool Bu::Conduit::isEos() | 131 | bool Bu::Conduit::isEos() |
132 | { | 132 | { |
133 | im.lock(); | 133 | im.lock(); |
134 | bool bRet = qb.isEos(); | 134 | bool bRet = qb.isEos(); |
135 | im.unlock(); | 135 | im.unlock(); |
136 | return bRet; | 136 | return bRet; |
137 | } | 137 | } |
138 | 138 | ||
139 | bool Bu::Conduit::isOpen() | 139 | bool Bu::Conduit::isOpen() |
140 | { | 140 | { |
141 | im.lock(); | 141 | im.lock(); |
142 | bool bRet = bOpen || (qb.getSize() > 0); | 142 | bool bRet = bOpen || (qb.getSize() > 0); |
143 | im.unlock(); | 143 | im.unlock(); |
144 | return bRet; | 144 | return bRet; |
145 | } | 145 | } |
146 | 146 | ||
147 | void Bu::Conduit::flush() | 147 | void Bu::Conduit::flush() |
@@ -150,57 +150,57 @@ void Bu::Conduit::flush() | |||
150 | 150 | ||
151 | bool Bu::Conduit::canRead() | 151 | bool Bu::Conduit::canRead() |
152 | { | 152 | { |
153 | im.lock(); | 153 | im.lock(); |
154 | bool bRet = qb.canRead(); | 154 | bool bRet = qb.canRead(); |
155 | im.unlock(); | 155 | im.unlock(); |
156 | return bRet; | 156 | return bRet; |
157 | } | 157 | } |
158 | 158 | ||
159 | bool Bu::Conduit::canWrite() | 159 | bool Bu::Conduit::canWrite() |
160 | { | 160 | { |
161 | im.lock(); | 161 | im.lock(); |
162 | bool bRet = qb.canWrite(); | 162 | bool bRet = qb.canWrite(); |
163 | im.unlock(); | 163 | im.unlock(); |
164 | return bRet; | 164 | return bRet; |
165 | } | 165 | } |
166 | 166 | ||
167 | bool Bu::Conduit::isReadable() | 167 | bool Bu::Conduit::isReadable() |
168 | { | 168 | { |
169 | im.lock(); | 169 | im.lock(); |
170 | bool bRet = qb.isReadable(); | 170 | bool bRet = qb.isReadable(); |
171 | im.unlock(); | 171 | im.unlock(); |
172 | return bRet; | 172 | return bRet; |
173 | } | 173 | } |
174 | 174 | ||
175 | bool Bu::Conduit::isWritable() | 175 | bool Bu::Conduit::isWritable() |
176 | { | 176 | { |
177 | im.lock(); | 177 | im.lock(); |
178 | bool bRet = qb.isWritable(); | 178 | bool bRet = qb.isWritable(); |
179 | im.unlock(); | 179 | im.unlock(); |
180 | return bRet; | 180 | return bRet; |
181 | } | 181 | } |
182 | 182 | ||
183 | bool Bu::Conduit::isSeekable() | 183 | bool Bu::Conduit::isSeekable() |
184 | { | 184 | { |
185 | im.lock(); | 185 | im.lock(); |
186 | bool bRet = qb.isSeekable(); | 186 | bool bRet = qb.isSeekable(); |
187 | im.unlock(); | 187 | im.unlock(); |
188 | return bRet; | 188 | return bRet; |
189 | } | 189 | } |
190 | 190 | ||
191 | bool Bu::Conduit::isBlocking() | 191 | bool Bu::Conduit::isBlocking() |
192 | { | 192 | { |
193 | im.lock(); | 193 | im.lock(); |
194 | bool bRet = bBlocking; | 194 | bool bRet = bBlocking; |
195 | im.unlock(); | 195 | im.unlock(); |
196 | return bRet; | 196 | return bRet; |
197 | } | 197 | } |
198 | 198 | ||
199 | void Bu::Conduit::setBlocking( bool bBlocking ) | 199 | void Bu::Conduit::setBlocking( bool bBlocking ) |
200 | { | 200 | { |
201 | im.lock(); | 201 | im.lock(); |
202 | this->bBlocking = bBlocking; | 202 | this->bBlocking = bBlocking; |
203 | im.unlock(); | 203 | im.unlock(); |
204 | } | 204 | } |
205 | 205 | ||
206 | void Bu::Conduit::setSize( Bu::size ) | 206 | void Bu::Conduit::setSize( Bu::size ) |
@@ -209,25 +209,25 @@ void Bu::Conduit::setSize( Bu::size ) | |||
209 | 209 | ||
210 | Bu::size Bu::Conduit::getSize() const | 210 | Bu::size Bu::Conduit::getSize() const |
211 | { | 211 | { |
212 | im.lock(); | 212 | im.lock(); |
213 | Bu::size sRet = qb.getSize(); | 213 | Bu::size sRet = qb.getSize(); |
214 | im.unlock(); | 214 | im.unlock(); |
215 | return sRet; | 215 | return sRet; |
216 | } | 216 | } |
217 | 217 | ||
218 | Bu::size Bu::Conduit::getBlockSize() const | 218 | Bu::size Bu::Conduit::getBlockSize() const |
219 | { | 219 | { |
220 | im.lock(); | 220 | im.lock(); |
221 | Bu::size sRet = qb.getBlockSize(); | 221 | Bu::size sRet = qb.getBlockSize(); |
222 | im.unlock(); | 222 | im.unlock(); |
223 | return sRet; | 223 | return sRet; |
224 | } | 224 | } |
225 | 225 | ||
226 | Bu::String Bu::Conduit::getLocation() const | 226 | Bu::String Bu::Conduit::getLocation() const |
227 | { | 227 | { |
228 | im.lock(); | 228 | im.lock(); |
229 | Bu::String sRet = qb.getLocation(); | 229 | Bu::String sRet = qb.getLocation(); |
230 | im.unlock(); | 230 | im.unlock(); |
231 | return sRet; | 231 | return sRet; |
232 | } | 232 | } |
233 | 233 | ||