2018-06-09 22:40:21 +02:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_DB_DATABASE_ENV_STATE_H
|
|
|
|
|
|
|
|
struct ircd::db::database::env::state
|
|
|
|
{
|
2018-08-16 13:48:21 +02:00
|
|
|
struct task;
|
2018-12-17 01:26:33 +01:00
|
|
|
struct pool;
|
2018-08-16 13:48:21 +02:00
|
|
|
|
|
|
|
static constexpr const size_t POOLS
|
|
|
|
{
|
|
|
|
rocksdb::Env::Priority::TOTAL
|
|
|
|
};
|
|
|
|
|
2018-12-17 01:26:33 +01:00
|
|
|
database &d;
|
|
|
|
std::array<std::unique_ptr<pool>, POOLS> pool;
|
2018-08-16 13:48:21 +02:00
|
|
|
|
2018-12-17 01:26:33 +01:00
|
|
|
state(database *const &);
|
2018-08-28 23:04:43 +02:00
|
|
|
~state() noexcept;
|
2018-08-16 13:48:21 +02:00
|
|
|
};
|
|
|
|
|
2018-12-17 01:26:33 +01:00
|
|
|
struct ircd::db::database::env::state::pool
|
|
|
|
{
|
|
|
|
using Priority = rocksdb::Env::Priority;
|
2018-12-27 23:56:40 +01:00
|
|
|
using IOPriority = rocksdb::Env::IOPriority;
|
2018-12-17 01:26:33 +01:00
|
|
|
|
|
|
|
static conf::item<size_t> stack_size;
|
|
|
|
|
|
|
|
database &d;
|
|
|
|
Priority pri;
|
2018-12-27 23:56:40 +01:00
|
|
|
IOPriority iopri;
|
2018-12-28 21:57:32 +01:00
|
|
|
ctx::dock dock;
|
2019-01-01 01:12:10 +01:00
|
|
|
uint64_t taskctr {0};
|
2018-12-17 01:26:33 +01:00
|
|
|
std::deque<task> tasks;
|
2018-12-28 21:57:32 +01:00
|
|
|
ctx::pool::opts popts;
|
2018-12-17 01:26:33 +01:00
|
|
|
ctx::pool p;
|
|
|
|
|
|
|
|
size_t cancel(void *const &tag);
|
|
|
|
void operator()(task &&);
|
|
|
|
|
|
|
|
void wait();
|
|
|
|
void join();
|
|
|
|
|
|
|
|
pool(database &, const Priority &);
|
|
|
|
~pool() noexcept;
|
|
|
|
};
|
|
|
|
|
2018-08-16 13:48:21 +02:00
|
|
|
struct ircd::db::database::env::state::task
|
|
|
|
{
|
|
|
|
void (*func)(void *arg);
|
|
|
|
void (*cancel)(void *arg);
|
|
|
|
void *arg;
|
2019-01-01 01:12:10 +01:00
|
|
|
uint64_t _id {0};
|
2018-06-09 22:40:21 +02:00
|
|
|
};
|