-
Notifications
You must be signed in to change notification settings - Fork 13.9k
server: move server-context to its own cpp|h #17595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
tools/server/server-context.h
Outdated
| struct server_slots_t { | ||
| ~server_slots_t(); | ||
| std::vector<server_slot*> data; | ||
| size_t size() const { return data.size(); } | ||
| server_slot & operator[](size_t idx) { return *(data[idx]); } | ||
| server_slot & operator[](size_t idx) const { return *(data[idx]); } | ||
| void clear(); | ||
| server_slot & create(); | ||
| struct iterator { | ||
| typename std::vector<server_slot*>::iterator it; | ||
| iterator(typename std::vector<server_slot*>::iterator i) : it(i) {} | ||
| server_slot & operator*() { return **it; } | ||
| iterator & operator++() { ++it; return *this; } | ||
| bool operator!=(const iterator& other) const { return it != other.it; } | ||
| }; | ||
| iterator begin() { return iterator(data.begin()); } | ||
| iterator end() { return iterator(data.end()); } | ||
| }; |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I think pimpl will be the cleaner way (and also easier for us, in case we need to add a new utility function into server_context)
Will implement this in my next commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented in 9a7b4f3 :
server_contextis moved toserver_context_impl(just renaming struct, the code is left untouched)- the new
server_contextonly expose: init(), load_model(), start_loop(), terminate()
@ggerganov Would be nice if you can review it in a short time frame (ideally before #17470 as some conflicts are inevitable). Thanks!
22039aa to
9a7b4f3
Compare
|
Nice, thanks for the speedy review! |
5f7b502 to
c5f8cdf
Compare
Extracted part of the changes in #17554 into this dedicated PR, just in case something goes wrong it's easier to trace back.
Compare to the proposed approach in the mentioned PR, which simply move everything to
.h, this PR do some extra thing:git mv, so that auto-merge can be more happy (I hope so, will need to test)server-context.h; so for example,server_slotis now a private implementationserver_context, consolidate everything into 4 main functions:init(),load_model(),start_loop(),terminate()This should allow easier integration of server inside CLI, while allow downstream to incorporate server as a library (cc @bandoti , probably pre-cursor to llamax)