Skip to content

Commit 3e8a338

Browse files
authored
Fix thread affinity handling on Android platform (#943)
1 parent 6eedf54 commit 3e8a338

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

.github/workflows/ubuntu_clang.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ jobs:
156156
matrix:
157157
mode: [ Release, Debug ]
158158

159-
runs-on: ubuntu-20.04
159+
runs-on: ubuntu-22.04
160160

161161
steps:
162162
- name: Checkout
@@ -165,8 +165,8 @@ jobs:
165165
- name: Install ninja-build tool
166166
uses: seanmiddleditch/gha-setup-ninja@master
167167

168-
- name: Install clang-7
169-
run: sudo apt-get install clang-7 clang++-7
168+
- name: Install clang-11
169+
run: sudo apt-get install clang-11 clang++-11
170170

171171
- name: ccache
172172
uses: hendrikmuhs/ccache-action@v1.2
@@ -175,7 +175,7 @@ jobs:
175175

176176
- name: Configure
177177
run: |
178-
CXX=clang++-7 CC=clang-7
178+
CXX=clang++-11 CC=clang-11
179179
cmake -B ${{github.workspace}}/build -G Ninja \
180180
-DCMAKE_BUILD_TYPE=${{matrix.mode}} \
181181
-DUSE_CCACHE=${{env.ccache}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
@@ -185,4 +185,4 @@ jobs:
185185

186186
- name: Test
187187
working-directory: ${{github.workspace}}/build
188-
run: ctest -C ${{matrix.mode}} -j 1 -V
188+
run: ctest -C ${{matrix.mode}} -j 1 -V

.github/workflows/ubuntu_gcc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ jobs:
126126
strategy:
127127
matrix:
128128
mode: [ Release, Debug ]
129-
runs-on: ubuntu-20.04
129+
runs-on: ubuntu-22.04
130130

131131
steps:
132132
- name: Checkout

include/ylt/coro_io/io_context_pool.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,14 @@ class io_context_pool {
190190
cpu_set_t cpuset;
191191
CPU_ZERO(&cpuset);
192192
CPU_SET(i, &cpuset);
193+
194+
#ifdef __ANDROID__
195+
const pid_t tid = pthread_gettid_np(threads.back()->native_handle());
196+
int rc = sched_setaffinity(tid, sizeof(cpu_set_t), &cpuset);
197+
#else
193198
int rc = pthread_setaffinity_np(threads.back()->native_handle(),
194199
sizeof(cpu_set_t), &cpuset);
200+
#endif
195201
if (rc != 0) {
196202
std::cerr << "Error calling pthread_setaffinity_np: " << rc << "\n";
197203
}

0 commit comments

Comments
 (0)