MCPcopy Create free account
hub / github.com/data61/MP-SPDZ / init

Method init

Tools/DiskVector.cpp:19–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19void DiskVectorBase::init(size_t byte_size)
20{
21 if (file.is_open())
22 throw runtime_error("resizing of disk memory not implemented");
23 else
24 {
25 auto dir_path = OnlineOptions::singleton.disk_memory;
26 boost::filesystem::path dir(dir_path);
27 if (not boost::filesystem::is_directory(dir))
28 throw std::runtime_error(dir_path + " is not a directory");
29
30 path = boost::filesystem::unique_path(
31 (dir / std::string("%%%%-%%%%-%%%%-%%%%")).native());
32
33 std::ofstream f(path.native());
34 f.close();
35 }
36
37 if (truncate(path.native().c_str(), byte_size))
38 throw std::runtime_error(
39 "cannot allocate " + std::to_string(byte_size) + " bytes in "
40 + path.native() + ": " + strerror(errno));
41
42 file.open(path, boost::iostreams::mapped_file::readwrite, byte_size);
43 assert(file.size() == byte_size);
44
45 boost::filesystem::remove(path);
46
47 signal(SIGBUS, sigbus_handler);
48}

Callers 1

start_networkingMethod · 0.45

Calls 5

runtime_errorFunction · 0.85
closeMethod · 0.80
to_stringFunction · 0.50
openMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected