[go: up one dir, main page]

Menu

[5a71d8]: / io / test.cpp  Maximize  Restore  History

Download this file

51 lines (37 with data), 1.2 kB

 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
/***************************************************************************
* test.cpp
*
* Sat Aug 24 23:52:27 2002
* Copyright 2002 Roman Dementiev
* dementiev@mpi-sb.mpg.de
****************************************************************************/
#include "io.h"
//! \example io/test.cpp
//! This is an example of use of \c \<stxxl\> files, requests, and
//! completion tracking mechanisms, i.e. \c stxxl::file , \c stxxl::request , and
//! \c stxxl::mc
using namespace stxxl;
struct my_handler
{
void operator () (request * ptr)
{
STXXL_MSG("Request completed: "<< ptr)
}
};
int main()
{
std::cout << sizeof(void *) << std::endl;
const int size = 1024 * 384;
char *buffer = new char[size];
char * paths[2] = {"/var/tmp/data1", "/var/tmp/data2"};
mmap_file file1(paths[0],file::CREAT | file::RDWR /* | file::DIRECT */,0);
file1.set_size(size*1024);
syscall_file file2(paths[1],file::CREAT | file::RDWR /* | file::DIRECT */,1);
request_ptr req[16];
unsigned i=0;
for(;i<16;i++)
req[i] = file2.awrite(buffer,i*size,size,my_handler());
wait_all(req,16);
delete [] buffer;
return 0;
}