Tcl Source Code

Check-in [de29c24e4b]
Login

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

Overview
Comment:merge sebres-event-perf-fix-busy-wait
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sebres-8-6-event-perf-branch
Files: files | file ages | folders
SHA1: de29c24e4b322554a09b23febaa1d88849244a70
User & Date: sebres 2017-07-13 16:04:31
Context
2019-03-08
11:34
3-way merge 8.6 - timerate is part of Tcl now (since TIP#527 got merged), conflicts resolved, merge-... check-in: 102958b94e user: sebres tags: sebres-8-6-event-perf-branch
2017-07-13
16:04
merge sebres-event-perf-fix-busy-wait check-in: de29c24e4b user: sebres tags: sebres-8-6-event-perf-branch
15:43
avoid busy wait if new short block-time will be set within service event-cycle (Tcl_DoOneEvent) prod... Closed-Leaf check-in: 834c53d3c6 user: sebres tags: sebres-event-perf-fix-busy-wait
2017-07-10
11:31
merge core-8-6-branch check-in: 1e6415bbda user: sebres tags: sebres-8-6-event-perf-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclNotify.c.

1540
1541
1542
1543
1544
1545
1546
1547
1548
1549








1550
1551
1552
1553
1554
1555
1556
1557
	 *
	 * We can stop also if works in block to event mode (e. g. block time was
	 * set outside an event source, that means timeout was set so exit loop
	 * also without event/result).
	 */

	result = 0;
	if (blockTimeWasSet) {
	    break;
	}








    } while ( !(flags & TCL_DONT_WAIT) );

done:
    /*
     * Reset block time earliest at the end of event cycle and restore mode.
     */
    if (tsdPtr->blockTimeServLev < tsdPtr->serviceLevel) {
	tsdPtr->blockTimeSet = 0;







|


>
>
>
>
>
>
>
>
|







1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
	 *
	 * We can stop also if works in block to event mode (e. g. block time was
	 * set outside an event source, that means timeout was set so exit loop
	 * also without event/result).
	 */

	result = 0;
	if ((flags & TCL_DONT_WAIT) || blockTimeWasSet) {
	    break;
	}

	/*
	 * Reset block time before continue event-cycle.
	 */
	if (tsdPtr->blockTimeServLev < tsdPtr->serviceLevel) {
	    tsdPtr->blockTimeSet = 0;
	    tsdPtr->blockTimeServLev = 0;
	}
    } while (1);

done:
    /*
     * Reset block time earliest at the end of event cycle and restore mode.
     */
    if (tsdPtr->blockTimeServLev < tsdPtr->serviceLevel) {
	tsdPtr->blockTimeSet = 0;
1594
1595
1596
1597
1598
1599
1600

1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616

1617

1618
1619
1620
1621

1622
1623
1624
1625
1626
1627
1628

1629
1630
1631
1632
1633


1634
1635
1636
1637
1638
1639
1640
    }

    /*
     * We need to turn off event servicing like we to in Tcl_DoOneEvent, to
     * avoid recursive calls.
     */


    tsdPtr->serviceMode = TCL_SERVICE_NONE;

    /*
     * Check async handlers first.
     */

    if (Tcl_AsyncReady()) {
	(void) Tcl_AsyncInvoke(NULL, 0);
    }

    /*
     * Make a single pass through all event sources, queued events, and idle
     * handlers. Note that we wait to update the notifier timer until the end
     * so we can avoid multiple changes.
     */


    tsdPtr->blockTimeSet = 0;


    SetUpEventSources(tsdPtr, TCL_ALL_EVENTS);
    CheckEventSources(tsdPtr, TCL_ALL_EVENTS);


    while (Tcl_ServiceEvent(0)) {
	result = 1;
    }
    if (TclServiceIdle()) {
	result = 1;
    }


    if (!tsdPtr->blockTimeSet) {
	Tcl_SetTimer(NULL);
    } else {
	Tcl_SetTimer(&tsdPtr->blockTime);
    }


    tsdPtr->serviceMode = TCL_SERVICE_ALL;
    return result;
}


/*
 *----------------------------------------------------------------------







>
















>

>




>
|






>
|
|
|
|
|
>
>







1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
    }

    /*
     * We need to turn off event servicing like we to in Tcl_DoOneEvent, to
     * avoid recursive calls.
     */

    tsdPtr->serviceLevel++;
    tsdPtr->serviceMode = TCL_SERVICE_NONE;

    /*
     * Check async handlers first.
     */

    if (Tcl_AsyncReady()) {
	(void) Tcl_AsyncInvoke(NULL, 0);
    }

    /*
     * Make a single pass through all event sources, queued events, and idle
     * handlers. Note that we wait to update the notifier timer until the end
     * so we can avoid multiple changes.
     */

    tsdPtr->inTraversal++;
    tsdPtr->blockTimeSet = 0;
    tsdPtr->blockTimeServLev = 0;

    SetUpEventSources(tsdPtr, TCL_ALL_EVENTS);
    CheckEventSources(tsdPtr, TCL_ALL_EVENTS);

    if (Tcl_ServiceEvent(0)) {
	while (Tcl_ServiceEvent(0)) {};
	result = 1;
    }
    if (TclServiceIdle()) {
	result = 1;
    }

    if (tsdPtr->inTraversal-- <= 1) {
	if (!tsdPtr->blockTimeSet) {
	    Tcl_SetTimer(NULL);
	} else {
	    Tcl_SetTimer(&tsdPtr->blockTime);
	}
    }
    tsdPtr->serviceLevel--;
    tsdPtr->serviceMode = TCL_SERVICE_ALL;
    return result;
}


/*
 *----------------------------------------------------------------------

Changes to generic/tclTimer.c.

1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
	}
	ckfree(tmrEvent);
    
    nextEvent:
	/* be sure that timer-list was not changed inside the proc call */
	if (currentEpoch != tsdPtr->timerListEpoch) {
	    /* timer-list was changed - stop processing */
	    tsdPtr->timerPending++;
	    break;
	}
    }

    /* pending timer events, so mark (queue) timer events  */
    if (tsdPtr->timerPending >= 1) {
    	tsdPtr->timerPending = 1;







<







1212
1213
1214
1215
1216
1217
1218

1219
1220
1221
1222
1223
1224
1225
	}
	ckfree(tmrEvent);
    
    nextEvent:
	/* be sure that timer-list was not changed inside the proc call */
	if (currentEpoch != tsdPtr->timerListEpoch) {
	    /* timer-list was changed - stop processing */

	    break;
	}
    }

    /* pending timer events, so mark (queue) timer events  */
    if (tsdPtr->timerPending >= 1) {
    	tsdPtr->timerPending = 1;