LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
tempdir.h File Reference

A scratch directory for the subprocess wrappers, the port's lineTempName. More...

#include <cctype>
#include <cerrno>
#include <cstdlib>
#include <string>
#include <vector>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include "line/util/error.h"
Include dependency graph for tempdir.h:

Go to the source code of this file.

Classes

class  line::util::TempDir

Namespaces

namespace  line
namespace  line::util

Functions

std::string line::util::make_temp_dir (const std::string &prefix, bool mountable=false)
 Create a private scratch directory named after its caller.

Detailed Description

A scratch directory for the subprocess wrappers, the port's lineTempName.

The wrappers hand an external binary a FILE, not a stream, so they need a private directory to put it in and to collect the tool's output from. The name comes from mkdtemp rather than from a counter or a PID: two solves of the same model running side by side (a parity sweep does exactly that) would otherwise write the same model.jmva and read each other's results.

The directory is REMOVED IN THE DESTRUCTOR, including on the exception path, because the wrappers throw on a tool failure and a leaked scratch directory per failed solve accumulates silently. keep() suppresses the removal for the case where the caller wants to inspect what was sent.

Definition in file tempdir.h.