17 std::ostream os(&buf);
19 <<
"test2" << std::endl <<
"test3" << 12345 << std::endl;
20 buf.
write(
"test4\ntest5\n", 12);
22 std::atomic<uint16_t> count(
m_total);
24 for (
int i = 0; i <
m_total; i++) {
25 std::string fname =
"/tmp/disk_io_test" + std::to_string(i);
26 int fd = open(fname.c_str(), O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
27 CPPUNIT_ASSERT(fd > -1);
30 task->
on_finish([
this, task, fd, &buf, &count] {
33 CPPUNIT_ASSERT(task->
bytes() ==
static_cast<std::streamsize
>(buf.
size()));
34 CPPUNIT_ASSERT(task->
bytes() == 34);
42 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
47 std::atomic<uint16_t> count(
m_total);
50 std::string fname =
"/tmp/disk_io_test0";
51 int fd = open(fname.c_str(), O_RDONLY);
52 CPPUNIT_ASSERT(fd > -1);
56 CPPUNIT_ASSERT(future_bytes.get() == 34);
60 for (
int i = 0; i <
m_total; i++) {
61 std::string fname =
"/tmp/disk_io_test" + std::to_string(i);
62 int fd = open(fname.c_str(), O_RDONLY);
63 CPPUNIT_ASSERT(fd > -1);
67 task->
on_finish([
this, task, fd, buf, &count, fname] {
70 CPPUNIT_ASSERT(task->
bytes() == 34);
72 unlink(fname.c_str());
80 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
static std::shared_future< std::streamsize > add_task(disk_io_task *task)
void on_finish(finish_func_worker_t f)
std::streamsize bytes() const