STXXL  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mem_file.h
Go to the documentation of this file.
1 /***************************************************************************
2  * include/stxxl/bits/io/mem_file.h
3  *
4  * Part of the STXXL. See http://stxxl.sourceforge.net
5  *
6  * Copyright (C) 2008 Andreas Beckmann <[email protected]>
7  * Copyright (C) 2009 Johannes Singler <[email protected]>
8  *
9  * Distributed under the Boost Software License, Version 1.0.
10  * (See accompanying file LICENSE_1_0.txt or copy at
11  * http://www.boost.org/LICENSE_1_0.txt)
12  **************************************************************************/
13 
14 #ifndef STXXL_IO_MEM_FILE_HEADER
15 #define STXXL_IO_MEM_FILE_HEADER
16 
18 #include <stxxl/bits/io/request.h>
19 
20 
22 
23 //! \addtogroup fileimpl
24 //! \{
25 
26 //! Implementation of file based on new[] and memcpy.
27 class mem_file : public disk_queued_file
28 {
29  char* ptr;
30  offset_type sz;
31 
32  mutex m_mutex; // sequentialize function calls
33 
34 public:
35  //! constructs file object.
37  int queue_id = DEFAULT_QUEUE, int allocator_id = NO_ALLOCATOR) : disk_queued_file(queue_id, allocator_id), ptr(NULL), sz(0)
38  { }
39  void serve(const request* req) throw (io_error);
40  ~mem_file();
41  offset_type size();
42  void set_size(offset_type newsize);
43  void lock();
44  void discard(offset_type offset, offset_type size);
45  const char * io_type() const;
46 };
47 
48 //! \}
49 
51 
52 #endif // !STXXL_IO_MEM_FILE_HEADER
offset_type sz
Definition: mem_file.h:30
char * ptr
Definition: mem_file.h:29
mem_file(int queue_id=DEFAULT_QUEUE, int allocator_id=NO_ALLOCATOR)
constructs file object.
Definition: mem_file.h:36
#define STXXL_BEGIN_NAMESPACE
Definition: namespace.h:16
Implementation of some file methods based on serving_request.
mutex m_mutex
Definition: mem_file.h:32
Implementation of file based on new[] and memcpy.
Definition: mem_file.h:27
void discard(StreamAlgorithm_ &in)
Reads stream content and discards it. Useful where you do not need the processed stream anymore...
Definition: stream.h:606
Request with basic properties like file and offset.
Definition: request.h:39
#define STXXL_END_NAMESPACE
Definition: namespace.h:17