0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 10:08:56 +02:00

ircd:Ⓜ️:media::block: Add zero-copy block::get() closure.

This commit is contained in:
Jason Volk 2019-09-17 13:52:44 -07:00
parent e357974d6f
commit dc1364c735
2 changed files with 10 additions and 0 deletions

View file

@ -49,6 +49,7 @@ namespace ircd::m::media::block
using closure = std::function<void (const const_buffer &)>;
bool prefetch(const string_view &hash);
bool get(const string_view &hash, const closure &);
const_buffer get(const mutable_buffer &out, const string_view &hash);
void set(const string_view &hash, const const_buffer &block);

View file

@ -679,6 +679,15 @@ ircd::m::media::block::get(const mutable_buffer &out,
return db::read(blocks, b58hash, out);
}
bool
IRCD_MODULE_EXPORT
ircd::m::media::block::get(const string_view &b58hash,
const closure &closure)
{
const db::gopts opts;
return blocks(b58hash, std::nothrow, closure, opts);
}
bool
IRCD_MODULE_EXPORT
ircd::m::media::block::prefetch(const string_view &b58hash)