Skip to content

Commit ea9ec7c

Browse files
authored
[orc-rt] Rename 'Session' variables to avoid ambiguity with type. NFCI. (#168999)
Re-using Session as a variable name risks confusion with the Session type.
1 parent e4a4bb0 commit ea9ec7c

File tree

7 files changed

+72
-88
lines changed

7 files changed

+72
-88
lines changed

orc-rt/include/orc-rt-c/WrapperFunction.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ typedef struct {
5454
* Asynchronous return function for an orc-rt wrapper function.
5555
*/
5656
typedef void (*orc_rt_WrapperFunctionReturn)(
57-
orc_rt_SessionRef Session, uint64_t CallId,
57+
orc_rt_SessionRef S, uint64_t CallId,
5858
orc_rt_WrapperFunctionBuffer ResultBytes);
5959

6060
/**
@@ -65,8 +65,7 @@ typedef void (*orc_rt_WrapperFunctionReturn)(
6565
* CallId holds a pointer to the context object for this particular call.
6666
* Return holds a pointer to the return function.
6767
*/
68-
typedef void (*orc_rt_WrapperFunction)(orc_rt_SessionRef Session,
69-
uint64_t CallId,
68+
typedef void (*orc_rt_WrapperFunction)(orc_rt_SessionRef S, uint64_t CallId,
7069
orc_rt_WrapperFunctionReturn Return,
7170
orc_rt_WrapperFunctionBuffer ArgBytes);
7271

orc-rt/include/orc-rt/SPSWrapperFunction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ template <typename SPSSig> struct SPSWrapperFunction {
124124
}
125125

126126
template <typename Handler>
127-
static void handle(orc_rt_SessionRef Session, uint64_t CallId,
127+
static void handle(orc_rt_SessionRef S, uint64_t CallId,
128128
orc_rt_WrapperFunctionReturn Return,
129129
WrapperFunctionBuffer ArgBytes, Handler &&H) {
130-
WrapperFunction::handle(Session, CallId, Return, std::move(ArgBytes),
130+
WrapperFunction::handle(S, CallId, Return, std::move(ArgBytes),
131131
WrapperFunctionSPSSerializer<SPSSig>(),
132132
std::forward<Handler>(H));
133133
}

orc-rt/include/orc-rt/SimpleNativeMemoryMap.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,21 @@ class SimpleNativeMemoryMap : public ResourceManager {
114114
} // namespace orc_rt
115115

116116
ORC_RT_SPS_INTERFACE void orc_rt_SimpleNativeMemoryMap_reserve_sps_wrapper(
117-
orc_rt_SessionRef Session, uint64_t CallId,
118-
orc_rt_WrapperFunctionReturn Return, orc_rt_WrapperFunctionBuffer ArgBytes);
117+
orc_rt_SessionRef S, uint64_t CallId, orc_rt_WrapperFunctionReturn Return,
118+
orc_rt_WrapperFunctionBuffer ArgBytes);
119119

120120
ORC_RT_SPS_INTERFACE void
121121
orc_rt_SimpleNativeMemoryMap_releaseMultiple_sps_wrapper(
122-
orc_rt_SessionRef Session, uint64_t CallId,
123-
orc_rt_WrapperFunctionReturn Return, orc_rt_WrapperFunctionBuffer ArgBytes);
122+
orc_rt_SessionRef S, uint64_t CallId, orc_rt_WrapperFunctionReturn Return,
123+
orc_rt_WrapperFunctionBuffer ArgBytes);
124124

125125
ORC_RT_SPS_INTERFACE void orc_rt_SimpleNativeMemoryMap_initialize_sps_wrapper(
126-
orc_rt_SessionRef Session, uint64_t CallId,
127-
orc_rt_WrapperFunctionReturn Return, orc_rt_WrapperFunctionBuffer ArgBytes);
126+
orc_rt_SessionRef S, uint64_t CallId, orc_rt_WrapperFunctionReturn Return,
127+
orc_rt_WrapperFunctionBuffer ArgBytes);
128128

129129
ORC_RT_SPS_INTERFACE void
130130
orc_rt_SimpleNativeMemoryMap_deinitializeMultiple_sps_wrapper(
131-
orc_rt_SessionRef Session, uint64_t CallId,
132-
orc_rt_WrapperFunctionReturn Return, orc_rt_WrapperFunctionBuffer ArgBytes);
131+
orc_rt_SessionRef S, uint64_t CallId, orc_rt_WrapperFunctionReturn Return,
132+
orc_rt_WrapperFunctionBuffer ArgBytes);
133133

134134
#endif // ORC_RT_SIMPLENATIVEMEMORYMAP_H

orc-rt/include/orc-rt/WrapperFunction.h

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,15 @@ using WFHandlerTraits = CallableTraitsHelper<WFHandlerTraitsImpl, C>;
137137

138138
template <typename Serializer> class StructuredYieldBase {
139139
public:
140-
StructuredYieldBase(orc_rt_SessionRef Session, uint64_t CallId,
141-
orc_rt_WrapperFunctionReturn Return, Serializer &&S)
142-
: Session(Session), CallId(CallId), Return(Return),
143-
S(std::forward<Serializer>(S)) {}
140+
StructuredYieldBase(orc_rt_SessionRef S, uint64_t CallId,
141+
orc_rt_WrapperFunctionReturn Return, Serializer &&Z)
142+
: S(S), CallId(CallId), Return(Return), Z(std::forward<Serializer>(Z)) {}
144143

145144
protected:
146-
orc_rt_SessionRef Session;
145+
orc_rt_SessionRef S;
147146
uint64_t CallId;
148147
orc_rt_WrapperFunctionReturn Return;
149-
std::decay_t<Serializer> S;
148+
std::decay_t<Serializer> Z;
150149
};
151150

152151
template <typename RetT, typename Serializer> class StructuredYield;
@@ -157,10 +156,10 @@ class StructuredYield<std::tuple<RetT>, Serializer>
157156
public:
158157
using StructuredYieldBase<Serializer>::StructuredYieldBase;
159158
void operator()(RetT &&R) {
160-
if (auto ResultBytes = this->S.result().serialize(std::forward<RetT>(R)))
161-
this->Return(this->Session, this->CallId, ResultBytes->release());
159+
if (auto ResultBytes = this->Z.result().serialize(std::forward<RetT>(R)))
160+
this->Return(this->S, this->CallId, ResultBytes->release());
162161
else
163-
this->Return(this->Session, this->CallId,
162+
this->Return(this->S, this->CallId,
164163
WrapperFunctionBuffer::createOutOfBandError(
165164
"Could not serialize wrapper function result data")
166165
.release());
@@ -173,8 +172,7 @@ class StructuredYield<std::tuple<>, Serializer>
173172
public:
174173
using StructuredYieldBase<Serializer>::StructuredYieldBase;
175174
void operator()() {
176-
this->Return(this->Session, this->CallId,
177-
WrapperFunctionBuffer().release());
175+
this->Return(this->S, this->CallId, WrapperFunctionBuffer().release());
178176
}
179177
};
180178

@@ -251,12 +249,12 @@ struct WrapperFunction {
251249
///
252250
///
253251
/// static void adder_add_async_sps_wrapper(
254-
/// orc_rt_SessionRef Session, uint64_t CallId,
252+
/// orc_rt_SessionRef S, uint64_t CallId,
255253
/// orc_rt_WrapperFunctionReturn Return,
256254
/// orc_rt_WrapperFunctionBuffer ArgBytes) {
257255
/// using SPSSig = SPSString(SPSExecutorAddr, int32_t, bool);
258256
/// SPSWrapperFunction<SPSSig>::handle(
259-
/// Session, CallId, Return, ArgBytes,
257+
/// S, CallId, Return, ArgBytes,
260258
/// WrapperFunction::handleWithAsyncMethod(&MyClass::myMethod));
261259
/// }
262260
/// @endcode
@@ -313,12 +311,12 @@ struct WrapperFunction {
313311
///
314312
///
315313
/// static void adder_add_sync_sps_wrapper(
316-
/// orc_rt_SessionRef Session, uint64_t CallId,
314+
/// orc_rt_SessionRef S, uint64_t CallId,
317315
/// orc_rt_WrapperFunctionReturn Return,
318316
/// orc_rt_WrapperFunctionBuffer ArgBytes) {
319317
/// using SPSSig = SPSString(SPSExecutorAddr, int32_t, bool);
320318
/// SPSWrapperFunction<SPSSig>::handle(
321-
/// Session, CallId, Return, ArgBytes,
319+
/// S, CallId, Return, ArgBytes,
322320
/// WrapperFunction::handleWithSyncMethod(&Adder::addSync));
323321
/// }
324322
/// @endcode
@@ -336,7 +334,7 @@ struct WrapperFunction {
336334
/// given Caller object.
337335
template <typename Caller, typename Serializer, typename ResultHandler,
338336
typename... ArgTs>
339-
static void call(Caller &&C, Serializer &&S, ResultHandler &&RH,
337+
static void call(Caller &&C, Serializer &&Z, ResultHandler &&RH,
340338
ArgTs &&...Args) {
341339
typedef CallableArgInfo<ResultHandler> ResultHandlerTraits;
342340
static_assert(std::is_void_v<typename ResultHandlerTraits::return_type>,
@@ -346,16 +344,15 @@ struct WrapperFunction {
346344
"Result-handler should have exactly one argument");
347345
typedef typename ResultHandlerTraits::args_tuple_type ResultTupleType;
348346

349-
if (auto ArgBytes = S.arguments().serialize(std::forward<ArgTs>(Args)...)) {
347+
if (auto ArgBytes = Z.arguments().serialize(std::forward<ArgTs>(Args)...)) {
350348
C(
351-
[RH = std::move(RH),
352-
S = std::move(S)](orc_rt_SessionRef Session,
353-
WrapperFunctionBuffer ResultBytes) mutable {
349+
[RH = std::move(RH), Z = std::move(Z)](
350+
orc_rt_SessionRef S, WrapperFunctionBuffer ResultBytes) mutable {
354351
if (const char *ErrMsg = ResultBytes.getOutOfBandError())
355352
RH(make_error<StringError>(ErrMsg));
356353
else
357354
RH(detail::ResultDeserializer<ResultTupleType, Serializer>::
358-
deserialize(std::move(ResultBytes), S));
355+
deserialize(std::move(ResultBytes), Z));
359356
},
360357
std::move(*ArgBytes));
361358
} else
@@ -368,9 +365,9 @@ struct WrapperFunction {
368365
/// This utility deserializes and serializes arguments and return values
369366
/// (using the given Serializer), and calls the given handler.
370367
template <typename Serializer, typename Handler>
371-
static void handle(orc_rt_SessionRef Session, uint64_t CallId,
368+
static void handle(orc_rt_SessionRef S, uint64_t CallId,
372369
orc_rt_WrapperFunctionReturn Return,
373-
WrapperFunctionBuffer ArgBytes, Serializer &&S,
370+
WrapperFunctionBuffer ArgBytes, Serializer &&Z,
374371
Handler &&H) {
375372
typedef detail::WFHandlerTraits<Handler> HandlerTraits;
376373
typedef typename HandlerTraits::ArgTupleType ArgTuple;
@@ -380,16 +377,16 @@ struct WrapperFunction {
380377
typedef typename CallableArgInfo<Yield>::args_tuple_type RetTupleType;
381378

382379
if (ArgBytes.getOutOfBandError())
383-
return Return(Session, CallId, ArgBytes.release());
380+
return Return(S, CallId, ArgBytes.release());
384381

385-
if (auto Args = S.arguments().template deserialize<ArgTuple>(ArgBytes))
382+
if (auto Args = Z.arguments().template deserialize<ArgTuple>(ArgBytes))
386383
std::apply(HandlerTraits::forwardArgsAsRequested(bind_front(
387384
std::forward<Handler>(H),
388385
detail::StructuredYield<RetTupleType, Serializer>(
389-
Session, CallId, Return, std::move(S)))),
386+
S, CallId, Return, std::move(Z)))),
390387
*Args);
391388
else
392-
Return(Session, CallId,
389+
Return(S, CallId,
393390
WrapperFunctionBuffer::createOutOfBandError(
394391
"Could not deserialize wrapper function arg data")
395392
.release());

orc-rt/lib/executor/SimpleNativeMemoryMap.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -367,45 +367,41 @@ Error SimpleNativeMemoryMap::recordDeallocActions(
367367
}
368368

369369
ORC_RT_SPS_INTERFACE void orc_rt_SimpleNativeMemoryMap_reserve_sps_wrapper(
370-
orc_rt_SessionRef Session, uint64_t CallId,
371-
orc_rt_WrapperFunctionReturn Return,
370+
orc_rt_SessionRef S, uint64_t CallId, orc_rt_WrapperFunctionReturn Return,
372371
orc_rt_WrapperFunctionBuffer ArgBytes) {
373372
using Sig = SPSExpected<SPSExecutorAddr>(SPSExecutorAddr, SPSSize);
374373
SPSWrapperFunction<Sig>::handle(
375-
Session, CallId, Return, ArgBytes,
374+
S, CallId, Return, ArgBytes,
376375
WrapperFunction::handleWithAsyncMethod(&SimpleNativeMemoryMap::reserve));
377376
}
378377

379378
ORC_RT_SPS_INTERFACE void
380379
orc_rt_SimpleNativeMemoryMap_releaseMultiple_sps_wrapper(
381-
orc_rt_SessionRef Session, uint64_t CallId,
382-
orc_rt_WrapperFunctionReturn Return,
380+
orc_rt_SessionRef S, uint64_t CallId, orc_rt_WrapperFunctionReturn Return,
383381
orc_rt_WrapperFunctionBuffer ArgBytes) {
384382
using Sig = SPSError(SPSExecutorAddr, SPSSequence<SPSExecutorAddr>);
385-
SPSWrapperFunction<Sig>::handle(Session, CallId, Return, ArgBytes,
383+
SPSWrapperFunction<Sig>::handle(S, CallId, Return, ArgBytes,
386384
WrapperFunction::handleWithAsyncMethod(
387385
&SimpleNativeMemoryMap::releaseMultiple));
388386
}
389387

390388
ORC_RT_SPS_INTERFACE void orc_rt_SimpleNativeMemoryMap_initialize_sps_wrapper(
391-
orc_rt_SessionRef Session, uint64_t CallId,
392-
orc_rt_WrapperFunctionReturn Return,
389+
orc_rt_SessionRef S, uint64_t CallId, orc_rt_WrapperFunctionReturn Return,
393390
orc_rt_WrapperFunctionBuffer ArgBytes) {
394391
using Sig = SPSExpected<SPSExecutorAddr>(
395392
SPSExecutorAddr, SPSSimpleNativeMemoryMapInitializeRequest);
396-
SPSWrapperFunction<Sig>::handle(Session, CallId, Return, ArgBytes,
393+
SPSWrapperFunction<Sig>::handle(S, CallId, Return, ArgBytes,
397394
WrapperFunction::handleWithAsyncMethod(
398395
&SimpleNativeMemoryMap::initialize));
399396
}
400397

401398
ORC_RT_SPS_INTERFACE void
402399
orc_rt_SimpleNativeMemoryMap_deinitializeMultiple_sps_wrapper(
403-
orc_rt_SessionRef Session, uint64_t CallId,
404-
orc_rt_WrapperFunctionReturn Return,
400+
orc_rt_SessionRef S, uint64_t CallId, orc_rt_WrapperFunctionReturn Return,
405401
orc_rt_WrapperFunctionBuffer ArgBytes) {
406402
using Sig = SPSError(SPSExecutorAddr, SPSSequence<SPSExecutorAddr>);
407403
SPSWrapperFunction<Sig>::handle(
408-
Session, CallId, Return, ArgBytes,
404+
S, CallId, Return, ArgBytes,
409405
WrapperFunction::handleWithAsyncMethod(
410406
&SimpleNativeMemoryMap::deinitializeMultiple));
411407
}

orc-rt/unittests/DirectCaller.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@ class DirectCaller {
2020
class DirectResultSender {
2121
public:
2222
virtual ~DirectResultSender() {}
23-
virtual void send(orc_rt_SessionRef Session,
23+
virtual void send(orc_rt_SessionRef S,
2424
orc_rt::WrapperFunctionBuffer ResultBytes) = 0;
25-
static void send(orc_rt_SessionRef Session, uint64_t CallId,
25+
static void send(orc_rt_SessionRef S, uint64_t CallId,
2626
orc_rt_WrapperFunctionBuffer ResultBytes) {
2727
std::unique_ptr<DirectResultSender>(
2828
reinterpret_cast<DirectResultSender *>(
2929
static_cast<uintptr_t>(CallId)))
30-
->send(Session, ResultBytes);
30+
->send(S, ResultBytes);
3131
}
3232
};
3333

3434
template <typename ImplFn>
3535
class DirectResultSenderImpl : public DirectResultSender {
3636
public:
3737
DirectResultSenderImpl(ImplFn &&Fn) : Fn(std::forward<ImplFn>(Fn)) {}
38-
void send(orc_rt_SessionRef Session,
38+
void send(orc_rt_SessionRef S,
3939
orc_rt::WrapperFunctionBuffer ResultBytes) override {
40-
Fn(Session, std::move(ResultBytes));
40+
Fn(S, std::move(ResultBytes));
4141
}
4242

4343
private:
@@ -52,21 +52,19 @@ class DirectCaller {
5252
}
5353

5454
public:
55-
DirectCaller(orc_rt_SessionRef Session, orc_rt_WrapperFunction Fn)
56-
: Session(Session), Fn(Fn) {}
55+
DirectCaller(orc_rt_SessionRef S, orc_rt_WrapperFunction Fn) : S(S), Fn(Fn) {}
5756

5857
template <typename HandleResultFn>
5958
void operator()(HandleResultFn &&HandleResult,
6059
orc_rt::WrapperFunctionBuffer ArgBytes) {
6160
auto DR =
6261
makeDirectResultSender(std::forward<HandleResultFn>(HandleResult));
63-
Fn(Session,
64-
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(DR.release())),
62+
Fn(S, static_cast<uint64_t>(reinterpret_cast<uintptr_t>(DR.release())),
6563
DirectResultSender::send, ArgBytes.release());
6664
}
6765

6866
private:
69-
orc_rt_SessionRef Session;
67+
orc_rt_SessionRef S;
7068
orc_rt_WrapperFunction Fn;
7169
};
7270

0 commit comments

Comments
 (0)