@@ -276,7 +276,8 @@ static ExecutorRef swift_task_getCurrentExecutorImpl() {
276
276
auto result = (currentTracking ? currentTracking->getActiveExecutor ()
277
277
: ExecutorRef::generic ());
278
278
#if SWIFT_TASK_PRINTF_DEBUG
279
- fprintf (stderr, " [%p] getting current executor %p\n " , pthread_self (), result.getIdentity ());
279
+ fprintf (stderr, " [%lu] getting current executor %p\n " ,
280
+ _swift_get_thread_id (), result.getIdentity ());
280
281
#endif
281
282
return result;
282
283
}
@@ -1181,7 +1182,8 @@ static Job *preprocessQueue(JobRef first,
1181
1182
1182
1183
void DefaultActorImpl::giveUpThread (RunningJobInfo runner) {
1183
1184
#if SWIFT_TASK_PRINTF_DEBUG
1184
- fprintf (stderr, " [%p] giving up thread for actor %p\n " , pthread_self (), this );
1185
+ fprintf (stderr, " [%lu] giving up thread for actor %p\n " ,
1186
+ _swift_get_thread_id (), this );
1185
1187
#endif
1186
1188
auto oldState = CurrentState.load (std::memory_order_acquire);
1187
1189
assert (oldState.Flags .isAnyRunningStatus ());
@@ -1245,8 +1247,10 @@ void DefaultActorImpl::giveUpThread(RunningJobInfo runner) {
1245
1247
}
1246
1248
1247
1249
#if SWIFT_TASK_PRINTF_DEBUG
1248
- # define LOG_STATE_TRANSITION fprintf (stderr, " [%p] actor %p transitioned from %zx to %zx (%s)\n " , \
1249
- pthread_self (), this, oldState.Flags.getOpaqueValue(), newState.Flags.getOpaqueValue(), __FUNCTION__)
1250
+ # define LOG_STATE_TRANSITION \
1251
+ fprintf (stderr, " [%lu] actor %p transitioned from %zx to %zx (%s)\n " , \
1252
+ _swift_get_thread_id (), this , oldState.Flags .getOpaqueValue (), \
1253
+ newState.Flags .getOpaqueValue (), __FUNCTION__)
1250
1254
#else
1251
1255
# define LOG_STATE_TRANSITION ((void )0 )
1252
1256
#endif
@@ -1503,7 +1507,8 @@ SWIFT_CC(swiftasync)
1503
1507
static void processDefaultActor(DefaultActorImpl *currentActor,
1504
1508
RunningJobInfo runner) {
1505
1509
#if SWIFT_TASK_PRINTF_DEBUG
1506
- fprintf (stderr, " [%p] processDefaultActor %p\n " , pthread_self (), currentActor);
1510
+ fprintf (stderr, " [%lu] processDefaultActor %p\n " ,
1511
+ _swift_get_thread_id (), currentActor);
1507
1512
#endif
1508
1513
DefaultActorImpl *actor = currentActor;
1509
1514
@@ -1529,7 +1534,8 @@ static void processDefaultActor(DefaultActorImpl *currentActor,
1529
1534
runner);
1530
1535
1531
1536
#if SWIFT_TASK_PRINTF_DEBUG
1532
- fprintf (stderr, " [%p] processDefaultActor %p claimed job %p\n " , pthread_self (), currentActor, job);
1537
+ fprintf (stderr, " [%lu] processDefaultActor %p claimed job %p\n " ,
1538
+ _swift_get_thread_id (), currentActor, job);
1533
1539
#endif
1534
1540
1535
1541
// If we failed to claim a job, we have nothing to do.
@@ -1551,7 +1557,8 @@ static void processDefaultActor(DefaultActorImpl *currentActor,
1551
1557
auto currentExecutor = trackingInfo.getActiveExecutor ();
1552
1558
1553
1559
#if SWIFT_TASK_PRINTF_DEBUG
1554
- fprintf (stderr, " [%p] processDefaultActor %p current executor now %p\n " , pthread_self (), currentActor, currentExecutor.getIdentity ());
1560
+ fprintf (stderr, " [%lu] processDefaultActor %p current executor now %p\n " ,
1561
+ _swift_get_thread_id (), currentActor, currentExecutor.getIdentity ());
1555
1562
#endif
1556
1563
1557
1564
if (!currentExecutor.isDefaultActor ()) {
@@ -1872,7 +1879,8 @@ static void runOnAssumedThread(AsyncTask *task, ExecutorRef executor,
1872
1879
trackingInfo.leave ();
1873
1880
1874
1881
#if SWIFT_TASK_PRINTF_DEBUG
1875
- fprintf (stderr, " [%p] leaving assumed thread, current executor is %p\n " , pthread_self (), executor.getIdentity ());
1882
+ fprintf (stderr, " [%lu] leaving assumed thread, current executor is %p\n " ,
1883
+ _swift_get_thread_id (), executor.getIdentity ());
1876
1884
#endif
1877
1885
1878
1886
if (executor.isDefaultActor ())
@@ -1888,7 +1896,9 @@ static void swift_task_switchImpl(SWIFT_ASYNC_CONTEXT AsyncContext *resumeContex
1888
1896
(trackingInfo ? trackingInfo->getActiveExecutor ()
1889
1897
: ExecutorRef::generic ());
1890
1898
#if SWIFT_TASK_PRINTF_DEBUG
1891
- fprintf (stderr, " [%p] trying to switch from executor %p to %p\n " , pthread_self (), currentExecutor.getIdentity (), newExecutor.getIdentity ());
1899
+ fprintf (stderr, " [%lu] trying to switch from executor %p to %p\n " ,
1900
+ _swift_get_thread_id (), currentExecutor.getIdentity (),
1901
+ newExecutor.getIdentity ());
1892
1902
#endif
1893
1903
1894
1904
// If the current executor is compatible with running the new executor,
@@ -1916,7 +1926,8 @@ static void swift_task_switchImpl(SWIFT_ASYNC_CONTEXT AsyncContext *resumeContex
1916
1926
!shouldYieldThread () &&
1917
1927
tryAssumeThreadForSwitch (newExecutor, runner)) {
1918
1928
#if SWIFT_TASK_PRINTF_DEBUG
1919
- fprintf (stderr, " [%p] switch succeeded, task %p assumed thread for executor %p\n " , pthread_self (), task, newExecutor.getIdentity ());
1929
+ fprintf (stderr, " [%lu] switch succeeded, task %p assumed thread for executor %p\n " ,
1930
+ _swift_get_thread_id (), task, newExecutor.getIdentity ());
1920
1931
#endif
1921
1932
giveUpThreadForSwitch (currentExecutor, runner);
1922
1933
// 'return' forces tail call
@@ -1926,7 +1937,8 @@ static void swift_task_switchImpl(SWIFT_ASYNC_CONTEXT AsyncContext *resumeContex
1926
1937
// Otherwise, just asynchronously enqueue the task on the given
1927
1938
// executor.
1928
1939
#if SWIFT_TASK_PRINTF_DEBUG
1929
- fprintf (stderr, " [%p] switch failed, task %p enqueued on executor %p\n " , pthread_self (), task, newExecutor.getIdentity ());
1940
+ fprintf (stderr, " [%lu] switch failed, task %p enqueued on executor %p\n " ,
1941
+ _swift_get_thread_id (), task, newExecutor.getIdentity ());
1930
1942
#endif
1931
1943
swift_task_enqueue (task, newExecutor);
1932
1944
}
@@ -1946,7 +1958,8 @@ void _swift_task_enqueueOnExecutor(Job *job, HeapObject *executor,
1946
1958
SWIFT_CC (swift)
1947
1959
static void swift_task_enqueueImpl(Job *job, ExecutorRef executor) {
1948
1960
#if SWIFT_TASK_PRINTF_DEBUG
1949
- fprintf (stderr, " [%p] enqueue job %p on executor %p\n " , pthread_self (), job, executor.getIdentity ());
1961
+ fprintf (stderr, " [%lu] enqueue job %p on executor %p\n " ,
1962
+ _swift_get_thread_id (), job, executor.getIdentity ());
1950
1963
#endif
1951
1964
1952
1965
assert (job && " no job provided" );
0 commit comments