Skip to content

Commit 044bbde

Browse files
committed
Move await_async impl to GraphQLService.cpp
1 parent 25d345f commit 044bbde

File tree

2 files changed

+39
-29
lines changed

2 files changed

+39
-29
lines changed

include/graphqlservice/GraphQLService.h

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ struct await_worker_queue : coro::suspend_always
177177
};
178178

179179
// Type-erased awaitable.
180-
class await_async : public coro::suspend_always
180+
class await_async
181181
{
182182
private:
183183
struct Concept
@@ -216,7 +216,7 @@ class await_async : public coro::suspend_always
216216
std::shared_ptr<T> _pimpl;
217217
};
218218

219-
const std::shared_ptr<Concept> _pimpl;
219+
const std::shared_ptr<const Concept> _pimpl;
220220

221221
public:
222222
// Type-erased explicit constructor for a custom awaitable.
@@ -227,36 +227,14 @@ class await_async : public coro::suspend_always
227227
}
228228

229229
// Default to immediate synchronous execution.
230-
await_async()
231-
: _pimpl { std::static_pointer_cast<Concept>(
232-
std::make_shared<Model<coro::suspend_never>>(std::make_shared<coro::suspend_never>())) }
233-
{
234-
}
230+
GRAPHQLSERVICE_EXPORT await_async();
235231

236232
// Implicitly convert a std::launch parameter used with std::async to an awaitable.
237-
await_async(std::launch launch)
238-
: _pimpl { ((launch & std::launch::async) == std::launch::async)
239-
? std::static_pointer_cast<Concept>(std::make_shared<Model<await_worker_thread>>(
240-
std::make_shared<await_worker_thread>()))
241-
: std::static_pointer_cast<Concept>(std::make_shared<Model<coro::suspend_never>>(
242-
std::make_shared<coro::suspend_never>())) }
243-
{
244-
}
233+
GRAPHQLSERVICE_EXPORT await_async(std::launch launch);
245234

246-
bool await_ready() const
247-
{
248-
return _pimpl->await_ready();
249-
}
250-
251-
void await_suspend(coro::coroutine_handle<> h) const
252-
{
253-
_pimpl->await_suspend(std::move(h));
254-
}
255-
256-
void await_resume() const
257-
{
258-
_pimpl->await_resume();
259-
}
235+
GRAPHQLSERVICE_EXPORT bool await_ready() const;
236+
GRAPHQLSERVICE_EXPORT void await_suspend(coro::coroutine_handle<> h) const;
237+
GRAPHQLSERVICE_EXPORT void await_resume() const;
260238
};
261239

262240
// Directive order matters, and some of them are repeatable. So rather than passing them in a

src/GraphQLService.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,38 @@ void await_worker_queue::resumePending()
230230
}
231231
}
232232

233+
// Default to immediate synchronous execution.
234+
await_async::await_async()
235+
: _pimpl { std::static_pointer_cast<Concept>(
236+
std::make_shared<Model<coro::suspend_never>>(std::make_shared<coro::suspend_never>())) }
237+
{
238+
}
239+
240+
// Implicitly convert a std::launch parameter used with std::async to an awaitable.
241+
await_async::await_async(std::launch launch)
242+
: _pimpl { ((launch & std::launch::async) == std::launch::async)
243+
? std::static_pointer_cast<Concept>(std::make_shared<Model<await_worker_thread>>(
244+
std::make_shared<await_worker_thread>()))
245+
: std::static_pointer_cast<Concept>(std::make_shared<Model<coro::suspend_never>>(
246+
std::make_shared<coro::suspend_never>())) }
247+
{
248+
}
249+
250+
bool await_async::await_ready() const
251+
{
252+
return _pimpl->await_ready();
253+
}
254+
255+
void await_async::await_suspend(coro::coroutine_handle<> h) const
256+
{
257+
_pimpl->await_suspend(std::move(h));
258+
}
259+
260+
void await_async::await_resume() const
261+
{
262+
_pimpl->await_resume();
263+
}
264+
233265
FieldParams::FieldParams(SelectionSetParams&& selectionSetParams, Directives directives)
234266
: SelectionSetParams(std::move(selectionSetParams))
235267
, fieldDirectives(std::move(directives))

0 commit comments

Comments
 (0)