File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -117,12 +117,16 @@ void Instance::warmup() {
117117}
118118
119119Session& Instance::startSession (const Session::InitParams params) {
120- if (m_session) {
120+ if (m_session. has_value () ) {
121121 throw_ex{} << " Session is already started. Stop it to start a new one." ;
122122 }
123123
124- m_session.reset ( new Session ( *this , m_lctx.get (), params) );
124+ m_session.emplace ( *this , m_lctx.get (), params);
125125 return *m_session;
126126}
127127
128+ void Instance::stopSession () noexcept {
129+ m_session.reset ();
130+ }
131+
128132} // namespace ac::llama
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ class AC_LLAMA_EXPORT Instance {
3535
3636 // only one session per instance can be active at a time
3737 Session& startSession (const Session::InitParams params);
38- void stopSession () noexcept { m_session. reset (); }
38+ void stopSession () noexcept ;
3939
4040 const Model& model () const noexcept { return m_model; }
4141 Sampler& sampler () noexcept { return m_sampler; }
@@ -44,7 +44,7 @@ class AC_LLAMA_EXPORT Instance {
4444 Model& m_model;
4545 Sampler m_sampler;
4646 astl::c_unique_ptr<llama_context> m_lctx;
47- std::unique_ptr <Session> m_session;
47+ std::optional <Session> m_session;
4848};
4949
5050} // namespace ac::llama
You can’t perform that action at this time.
0 commit comments