2018-06-09 22:40:21 +02:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
2019-07-21 00:29:33 +02:00
|
|
|
// Copyright (C) 2016-2019 Jason Volk <jason@zemos.net>
|
2018-06-09 22:40:21 +02:00
|
|
|
//
|
|
|
|
// 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
|
2019-07-21 00:29:33 +02:00
|
|
|
#define HAVE_IRCD_DB_ENV_STATE_H
|
2018-06-09 22:40:21 +02:00
|
|
|
|
2020-09-22 04:14:17 +02:00
|
|
|
struct [[gnu::visibility("hidden")]]
|
|
|
|
ircd::db::database::env::state
|
2018-06-09 22:40:21 +02:00
|
|
|
{
|
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 &);
|
2019-07-21 00:08:25 +02:00
|
|
|
state(state &&) = delete;
|
|
|
|
state(const state &) = delete;
|
2018-08-28 23:04:43 +02:00
|
|
|
~state() noexcept;
|
2018-08-16 13:48:21 +02:00
|
|
|
};
|
|
|
|
|
2020-09-22 04:14:17 +02:00
|
|
|
struct [[gnu::visibility("hidden")]]
|
|
|
|
ircd::db::database::env::state::pool
|
2018-12-17 01:26:33 +01:00
|
|
|
{
|
|
|
|
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;
|
2019-07-20 23:56:10 +02:00
|
|
|
char namebuf[16];
|
|
|
|
string_view name;
|
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 &);
|
2019-07-21 00:08:25 +02:00
|
|
|
pool(pool &&) = delete;
|
|
|
|
pool(const pool &) = delete;
|
2018-12-17 01:26:33 +01:00
|
|
|
~pool() noexcept;
|
|
|
|
};
|
|
|
|
|
2020-09-22 04:14:17 +02:00
|
|
|
struct [[gnu::visibility("hidden")]]
|
|
|
|
ircd::db::database::env::state::task
|
2018-08-16 13:48:21 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
};
|