Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/sw/redis++/event_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ EventLoop::EventLoop() {
_event_async = _create_uv_async(_event_callback);
_stop_async = _create_uv_async(_stop_callback);

_loop_thread = std::thread([this]() { uv_run(this->_loop.get(), UV_RUN_DEFAULT); });
_loop_thread = std::thread([this]() {
pthread_setname_np(pthread_self(), "redis-ev");
uv_run(this->_loop.get(), UV_RUN_DEFAULT);
});
}

EventLoop::~EventLoop() {
Expand All @@ -56,6 +59,13 @@ void EventLoop::stop() {
}
}

int EventLoop::bind_cpu(int cpu_id) {
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(cpu_id, &cpuset);
return pthread_setaffinity_np(_loop_thread.native_handle(), sizeof(cpu_set_t), &cpuset);
}

void EventLoop::unwatch(AsyncConnectionSPtr connection, std::exception_ptr err) {
assert(connection);

Expand Down
2 changes: 2 additions & 0 deletions src/sw/redis++/event_loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class EventLoop {

void stop();

int EventLoop::bind_cpu(int cpu_id)

private:
static void _connect_callback(const redisAsyncContext *ctx, int status);

Expand Down