-
Notifications
You must be signed in to change notification settings - Fork 2
/
buffer.h
77 lines (63 loc) · 2.09 KB
/
buffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// This file is part of par2cmdline (a PAR 2.0 compatible file verification and
// repair tool). See http://parchive.sourceforge.net for details of PAR 2.0.
//
// Copyright (c) 2008 Vincent Tan, created 2008-09-20. buffer.h
//
// par2cmdline is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// par2cmdline is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Modifications for concurrent processing, async I/O, Unicode support, and
// hierarchial directory support are Copyright (c) 2007-2008 Vincent Tan.
// Search for "#if WANT_CONCURRENT" for concurrent code.
// Concurrent processing utilises Intel Thread Building Blocks 2.0,
// Copyright (c) 2007 Intel Corp.
#include "par2cmdline.h"
#undef DEBUG_BUFFERS
// implements a refcounted buffer
#if GPGPU_CUDA
#include "cuda.h"
#endif
class buffer {
private:
u8* buffer_;
#if GPGPU_CUDA
bool buffer_allocated_by_gpu_;
#endif
#if !defined(NDEBUG) && defined(DEBUG_BUFFERS)
public:
unsigned id_;
private:
#endif
//buffer(buffer&);
//buffer& operator=(const buffer&);
public:
buffer(void);
~buffer(void);
bool alloc(size_t sz);
const u8* get(void) const { return buffer_; }
u8* get(void) { return buffer_; }
}; // buffer
#if WANT_CONCURRENT
class rcbuffer : public buffer {
private:
tbb::atomic<int> refcount_;
friend class pipeline_state_base;
bool try_to_acquire(void);
protected:
rcbuffer(void);
public:
void add_ref(void);
int release(void);
}; // rcbuffer
#endif