Tcl Source Code

Check-in [f26dfbb645]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:macosx: Tcl_Sleep -> TclpUSleep (provides microseconds sleep, fixed unresolved external "TclpUSleep" bug).
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | sebres-8-5-event-perf-branch
Files: files | file ages | folders
SHA3-256: f26dfbb645ecaedcbbd09a597161e8418dbc0ae7b5bdabbfc6467bd5d8efea78
User & Date: sebres 2019-03-09 19:07:38.694
Context
2019-03-09
20:07
non-native time scale fixed: do scale time only once (not in cycle, since all other times used in ca... check-in: f20b5264a3 user: sebres tags: sebres-8-5-event-perf-branch
19:07
macosx: Tcl_Sleep -> TclpUSleep (provides microseconds sleep, fixed unresolved external "TclpUSleep"... check-in: f26dfbb645 user: sebres tags: sebres-8-5-event-perf-branch
18:41
TclpScaleUTime fixed typo, only if native scaling used (tclScaleTimeProcPtr == NativeScaleTime) the ... check-in: fca5fb3444 user: sebres tags: sebres-8-5-event-perf-branch
Changes
Unified Diff Ignore Whitespace Patch
Changes to macosx/tclMacOSXNotify.c.
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500

    return changeWaitingList;
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_Sleep --
 *
 *	Delay execution for the specified number of milliseconds.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Time passes.
 *
 *----------------------------------------------------------------------
 */

void
Tcl_Sleep(
    int ms)			/* Number of milliseconds to sleep. */
{
    Tcl_Time vdelay;
    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);

    if (ms <= 0) {
	return;
    }

    /*
     * TIP #233: Scale from virtual time to real-time.
     */

    vdelay.sec  = ms / 1000;
    vdelay.usec = (ms % 1000) * 1000;
    tclScaleTimeProcPtr(&vdelay, tclTimeClientData);


    if (tsdPtr->runLoop) {
	CFTimeInterval waitTime;
	CFRunLoopTimerRef runLoopTimer = tsdPtr->runLoopTimer;
	CFAbsoluteTime nextTimerFire = 0, waitEnd, now;
	SInt32 runLoopStatus;

	waitTime = vdelay.sec + 1.0e-6 * vdelay.usec;
 	now = CFAbsoluteTimeGetCurrent();
	waitEnd = now + waitTime;

	if (runLoopTimer) {
	    nextTimerFire = CFRunLoopTimerGetNextFireDate(runLoopTimer);
	    if (nextTimerFire < waitEnd) {
		CFRunLoopTimerSetNextFireDate(runLoopTimer, now +







|

|











|
|

<


|
|





|
<
<
<
<







|







1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470

1471
1472
1473
1474
1475
1476
1477
1478
1479
1480




1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495

    return changeWaitingList;
}

/*
 *----------------------------------------------------------------------
 *
 * TclpUSleep --
 *
 *	Delay execution for the specified time (in microseconds).
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	Time passes.
 *
 *----------------------------------------------------------------------
 */

void
TclpUSleep(
    Tcl_WideInt usec)	/* Time to sleep. */
{

    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);

    if (usec <= 0) { /* force one context switch */
	usec = 0;
    }

    /*
     * TIP #233: Scale from virtual time to real-time.
     */
    TclpScaleUTime(&usec);





    if (tsdPtr->runLoop) {
	CFTimeInterval waitTime;
	CFRunLoopTimerRef runLoopTimer = tsdPtr->runLoopTimer;
	CFAbsoluteTime nextTimerFire = 0, waitEnd, now;
	SInt32 runLoopStatus;

	waitTime = (usec / 1000000) + 1.0e-6 * (usec % 1000000);
 	now = CFAbsoluteTimeGetCurrent();
	waitEnd = now + waitTime;

	if (runLoopTimer) {
	    nextTimerFire = CFRunLoopTimerGetNextFireDate(runLoopTimer);
	    if (nextTimerFire < waitEnd) {
		CFRunLoopTimerSetNextFireDate(runLoopTimer, now +
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
	tsdPtr->sleeping = 0;
 	if (runLoopTimer) {
	    CFRunLoopTimerSetNextFireDate(runLoopTimer, nextTimerFire);
	}
    } else {
	struct timespec waitTime;

	waitTime.tv_sec = vdelay.sec;
	waitTime.tv_nsec = vdelay.usec * 1000;
	while (nanosleep(&waitTime, &waitTime));
    }
}

/*
 *----------------------------------------------------------------------
 *







|
|







1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
	tsdPtr->sleeping = 0;
 	if (runLoopTimer) {
	    CFRunLoopTimerSetNextFireDate(runLoopTimer, nextTimerFire);
	}
    } else {
	struct timespec waitTime;

	waitTime.tv_sec = (usec / 1000000);
	waitTime.tv_nsec = (usec % 1000000) * 1000;
	while (nanosleep(&waitTime, &waitTime));
    }
}

/*
 *----------------------------------------------------------------------
 *