Tcl Source Code

Check-in [e619eb2ac3]
Login

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

Overview
Comment:merge (integrate) sebres-event-perf-fix-busy-wait
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sebres-8-5-event-perf-branch
Files: files | file ages | folders
SHA1: e619eb2ac31e46b5b5f3cff2eec798a9d2f17b02
User & Date: sebres 2017-07-13 15:46:42
Context
2019-03-08
04:05
merge sebres-8-5-timerate (prepare for consolidation with 8.5) check-in: ca89c4e5a7 user: sebres tags: sebres-8-5-event-perf-branch
2017-07-13
15:46
merge (integrate) sebres-event-perf-fix-busy-wait check-in: e619eb2ac3 user: sebres tags: sebres-8-5-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:17
merge core-8-5-branch check-in: 230de0c28e user: sebres tags: sebres-8-5-event-perf-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclNotify.c.

1522
1523
1524
1525
1526
1527
1528
1529
1530
1531








1532
1533
1534
1535
1536
1537
1538
1539
	 *
	 * 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;







|


>
>
>
>
>
>
>
>
|







1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
	 *
	 * 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;
1575
1576
1577
1578
1579
1580
1581

1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
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
    }

    /*
     * 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;
}

/*
 *----------------------------------------------------------------------
 *







>
















>

>




>
|






>
|
|
|
|
|
>
>







1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
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
    }

    /*
     * 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.

1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
	}
	ckfree((char *) 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;







<







1204
1205
1206
1207
1208
1209
1210

1211
1212
1213
1214
1215
1216
1217
	}
	ckfree((char *) 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;