Skip to content

Commit a595a0b

Browse files
committed
moveonly: add mp/type-threadmap.h
1 parent e834ebd commit a595a0b

File tree

6 files changed

+45
-29
lines changed

6 files changed

+45
-29
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ set(MP_PUBLIC_HEADERS
6060
include/mp/type-set.h
6161
include/mp/type-string.h
6262
include/mp/type-struct.h
63+
include/mp/type-threadmap.h
6364
include/mp/type-tuple.h
6465
include/mp/type-vector.h
6566
include/mp/type-void.h

example/types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
#include <mp/type-decay.h>
1010
#include <mp/type-interface.h>
1111
#include <mp/type-string.h>
12+
#include <mp/type-threadmap.h>
1213

1314
#endif // EXAMPLE_TYPES_H

include/mp/proxy-types.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -297,35 +297,6 @@ void PassField(Priority<0>, TypeList<>, ServerContext& server_context, const Fn&
297297
BuildField(TypeList<>(), server_context, Make<StructField, Accessor>(results));
298298
}
299299

300-
template <>
301-
struct ProxyServer<ThreadMap> final : public virtual ThreadMap::Server
302-
{
303-
public:
304-
ProxyServer(Connection& connection);
305-
kj::Promise<void> makeThread(MakeThreadContext context) override;
306-
Connection& m_connection;
307-
};
308-
309-
template <typename Output>
310-
void CustomBuildField(TypeList<>,
311-
Priority<1>,
312-
InvokeContext& invoke_context,
313-
Output&& output,
314-
typename std::enable_if<std::is_same<decltype(output.get()), ThreadMap::Client>::value>::type* enable = nullptr)
315-
{
316-
output.set(kj::heap<ProxyServer<ThreadMap>>(invoke_context.connection));
317-
}
318-
319-
template <typename Input>
320-
decltype(auto) CustomReadField(TypeList<>,
321-
Priority<1>,
322-
InvokeContext& invoke_context,
323-
Input&& input,
324-
typename std::enable_if<std::is_same<decltype(input.get()), ThreadMap::Client>::value>::type* enable = nullptr)
325-
{
326-
invoke_context.connection.m_thread_map = input.get();
327-
}
328-
329300
template <typename Derived, size_t N = 0>
330301
struct IterateFieldsHelper
331302
{

include/mp/type-threadmap.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) 2025 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef MP_PROXY_TYPE_THREADMAP_H
6+
#define MP_PROXY_TYPE_THREADMAP_H
7+
8+
#include <mp/util.h>
9+
10+
namespace mp {
11+
template <>
12+
struct ProxyServer<ThreadMap> final : public virtual ThreadMap::Server
13+
{
14+
public:
15+
ProxyServer(Connection& connection);
16+
kj::Promise<void> makeThread(MakeThreadContext context) override;
17+
Connection& m_connection;
18+
};
19+
20+
template <typename Output>
21+
void CustomBuildField(TypeList<>,
22+
Priority<1>,
23+
InvokeContext& invoke_context,
24+
Output&& output,
25+
typename std::enable_if<std::is_same<decltype(output.get()), ThreadMap::Client>::value>::type* enable = nullptr)
26+
{
27+
output.set(kj::heap<ProxyServer<ThreadMap>>(invoke_context.connection));
28+
}
29+
30+
template <typename Input>
31+
decltype(auto) CustomReadField(TypeList<>,
32+
Priority<1>,
33+
InvokeContext& invoke_context,
34+
Input&& input,
35+
typename std::enable_if<std::is_same<decltype(input.get()), ThreadMap::Client>::value>::type* enable = nullptr)
36+
{
37+
invoke_context.connection.m_thread_map = input.get();
38+
}
39+
} // namespace mp
40+
41+
#endif // MP_PROXY_TYPE_THREADMAP_H

src/mp/proxy.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <mp/proxy-io.h>
88
#include <mp/proxy-types.h>
99
#include <mp/proxy.capnp.h>
10+
#include <mp/type-threadmap.h>
1011
#include <mp/util.h>
1112

1213
#include <assert.h>

test/mp/test/foo-types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <mp/type-set.h>
1616
#include <mp/type-string.h>
1717
#include <mp/type-struct.h>
18+
#include <mp/type-threadmap.h>
1819
#include <mp/type-vector.h>
1920

2021
namespace mp {

0 commit comments

Comments
 (0)