/usr/include/stxxl/bits/io/request.h is in libstxxl-dev 1.3.1-5ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | /***************************************************************************
* include/stxxl/bits/io/request.h
*
* Part of the STXXL. See http://stxxl.sourceforge.net
*
* Copyright (C) 2002 Roman Dementiev <dementiev@mpi-sb.mpg.de>
* Copyright (C) 2008 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
**************************************************************************/
#ifndef STXXL_IO__REQUEST_H_
#define STXXL_IO__REQUEST_H_
#include <cassert>
#include <stxxl/bits/namespace.h>
#include <stxxl/bits/io/request_interface.h>
#include <stxxl/bits/common/mutex.h>
#include <stxxl/bits/common/exceptions.h>
#include <stxxl/bits/io/completion_handler.h>
#include <stxxl/bits/compat_unique_ptr.h>
#include <stxxl/bits/verbose.h>
__STXXL_BEGIN_NAMESPACE
//! \addtogroup iolayer
//! \{
#define BLOCK_ALIGN 4096
class file;
class request_ptr;
//! \brief Request with basic properties like file and offset.
class request : virtual public request_interface
{
friend class request_ptr;
protected:
completion_handler on_complete;
int ref_cnt;
compat_unique_ptr<stxxl::io_error>::result error;
mutex ref_cnt_mutex;
protected:
file * file_;
void * buffer;
offset_type offset;
size_type bytes;
request_type type;
void completed();
public:
// returns number of references
int nref()
{
scoped_mutex_lock Lock(ref_cnt_mutex);
return ref_cnt;
}
request(const completion_handler & on_compl,
file * file__,
void * buffer_,
offset_type offset_,
size_type bytes_,
request_type type_);
virtual ~request();
file * get_file() const { return file_; }
void * get_buffer() const { return buffer; }
offset_type get_offset() const { return offset; }
size_type get_size() const { return bytes; }
request_type get_type() const { return type; }
void check_alignment() const;
std::ostream & print(std::ostream & out) const;
//! \brief Inform the request object that an error occurred
//! during the I/O execution
void error_occured(const char * msg)
{
error.reset(new stxxl::io_error(msg));
}
//! \brief Inform the request object that an error occurred
//! during the I/O execution
void error_occured(const std::string & msg)
{
error.reset(new stxxl::io_error(msg));
}
//! \brief Rises an exception if there were error with the I/O
void check_errors() throw (stxxl::io_error)
{
if (error.get())
throw *(error.get());
}
private:
void add_ref()
{
scoped_mutex_lock Lock(ref_cnt_mutex);
ref_cnt++;
STXXL_VERBOSE3("[" << static_cast<void *>(this) << "] request::add_ref(): added reference, ref_cnt=" << ref_cnt);
}
bool sub_ref()
{
int val;
{
scoped_mutex_lock Lock(ref_cnt_mutex);
val = --ref_cnt;
STXXL_VERBOSE3("[" << static_cast<void *>(this) << "] request::sub_ref(): subtracted reference, ref_cnt=" << ref_cnt);
}
assert(val >= 0);
return (val == 0);
}
protected:
void check_nref(bool after = false)
{
if (nref() < 2)
check_nref_failed(after);
}
private:
void check_nref_failed(bool after);
};
inline std::ostream & operator << (std::ostream & out, const request & req)
{
return req.print(out);
}
//! \}
__STXXL_END_NAMESPACE
#endif // !STXXL_IO__REQUEST_H_
// vim: et:ts=4:sw=4
|