1672 evaluated after delta milliseconds. The process which installs this timed |
1672 evaluated after delta milliseconds. The process which installs this timed |
1673 block will be interrupted for execution of the block. |
1673 block will be interrupted for execution of the block. |
1674 (if it is running, the interrupt will occur in whatever method it is |
1674 (if it is running, the interrupt will occur in whatever method it is |
1675 executing; if it is suspended, it will be resumed). |
1675 executing; if it is suspended, it will be resumed). |
1676 The block will be removed from the timed-block list after evaluation |
1676 The block will be removed from the timed-block list after evaluation |
1677 (i.e. it will trigger only once)." |
1677 (i.e. it will trigger only once). |
|
1678 Returns an ID, which can be used in #removeTimeoutWidthID:" |
1678 |
1679 |
1679 ^ self addTimedBlock:aBlock for:activeProcess afterMilliseconds:delta |
1680 ^ self addTimedBlock:aBlock for:activeProcess afterMilliseconds:delta |
|
1681 |
|
1682 "Modified: 23.9.1996 / 14:33:59 / cg" |
1680 ! |
1683 ! |
1681 |
1684 |
1682 addTimedBlock:aBlock afterSeconds:delta |
1685 addTimedBlock:aBlock afterSeconds:delta |
1683 "add the argument, aBlock to the list of time-scheduled-blocks. |
1686 "add the argument, aBlock to the list of time-scheduled-blocks. |
1684 to be evaluated after delta seconds. The process which installs this timed |
1687 to be evaluated after delta seconds. The process which installs this timed |
1685 block will be interrupted for execution of the block. |
1688 block will be interrupted for execution of the block. |
1686 (if it is running, the interrupt will occur in whatever method it is |
1689 (if it is running, the interrupt will occur in whatever method it is |
1687 executing; if it is suspended, it will be resumed). |
1690 executing; if it is suspended, it will be resumed). |
1688 The block will be removed from the timed-block list after evaluation |
1691 The block will be removed from the timed-block list after evaluation |
1689 (i.e. it will trigger only once)." |
1692 (i.e. it will trigger only once). |
1690 |
1693 Returns an ID, which can be used in #removeTimeoutWidthID:" |
1691 self addTimedBlock:aBlock for:activeProcess afterMilliseconds:(delta * 1000) rounded |
1694 |
|
1695 ^ self addTimedBlock:aBlock for:activeProcess afterMilliseconds:(delta * 1000) rounded |
|
1696 |
|
1697 "Modified: 23.9.1996 / 14:34:04 / cg" |
1692 ! |
1698 ! |
1693 |
1699 |
1694 addTimedBlock:aBlock atMilliseconds:aMillisecondTime |
1700 addTimedBlock:aBlock atMilliseconds:aMillisecondTime |
1695 "add the argument, aBlock to the list of time-scheduled-blocks; to be |
1701 "add the argument, aBlock to the list of time-scheduled-blocks; to be |
1696 evaluated when the millisecondClock value passes aMillisecondTime. |
1702 evaluated when the millisecondClock value passes aMillisecondTime. |
1697 The process which installs this timed block will be interrupted for |
1703 The process which installs this timed block will be interrupted for |
1698 execution of the block. |
1704 execution of the block. |
1699 (if it is running, the interrupt will occur in whatever method it is |
1705 (if it is running, the interrupt will occur in whatever method it is |
1700 executing; if it is suspended, it will be resumed). |
1706 executing; if it is suspended, it will be resumed). |
1701 The block will be removed from the timed-block list after evaluation |
1707 The block will be removed from the timed-block list after evaluation |
1702 (i.e. it will trigger only once)." |
1708 (i.e. it will trigger only once). |
1703 |
1709 Returns an ID, which can be used in #removeTimeoutWidthID:" |
1704 self addTimedBlock:aBlock for:activeProcess atMilliseconds:aMillisecondTime |
1710 |
|
1711 ^ self addTimedBlock:aBlock for:activeProcess atMilliseconds:aMillisecondTime |
|
1712 |
|
1713 "Modified: 23.9.1996 / 14:34:09 / cg" |
1705 ! |
1714 ! |
1706 |
1715 |
1707 addTimedBlock:aBlock for:aProcess afterMilliseconds:delta |
1716 addTimedBlock:aBlock for:aProcess afterMilliseconds:delta |
1708 "add the argument, aBlock to the list of time-scheduled-blocks; to be |
1717 "add the argument, aBlock to the list of time-scheduled-blocks; to be |
1709 evaluated after delta milliseconds. The process specified by the argument, |
1718 evaluated after delta milliseconds. The process specified by the argument, |
1711 (if it is running, the interrupt will occur in whatever method it is |
1720 (if it is running, the interrupt will occur in whatever method it is |
1712 executing; if it is suspended, it will be resumed). |
1721 executing; if it is suspended, it will be resumed). |
1713 If aProcess is nil, the block will be evaluated by the scheduler itself |
1722 If aProcess is nil, the block will be evaluated by the scheduler itself |
1714 (which is dangerous - the block should not raise any error conditions). |
1723 (which is dangerous - the block should not raise any error conditions). |
1715 The block will be removed from the timed-block list after evaluation |
1724 The block will be removed from the timed-block list after evaluation |
1716 (i.e. it will trigger only once)." |
1725 (i.e. it will trigger only once). |
1717 |
1726 Returns an ID, which can be used in #removeTimeoutWidthID:" |
1718 |now then wasBlocked| |
1727 |
|
1728 |now then wasBlocked id| |
1719 |
1729 |
1720 wasBlocked := OperatingSystem blockInterrupts. |
1730 wasBlocked := OperatingSystem blockInterrupts. |
1721 now := OperatingSystem getMillisecondTime. |
1731 now := OperatingSystem getMillisecondTime. |
1722 then := OperatingSystem millisecondTimeAdd:now and:delta. |
1732 then := OperatingSystem millisecondTimeAdd:now and:delta. |
1723 self addTimedBlock:aBlock for:aProcess atMilliseconds:then. |
1733 id := self addTimedBlock:aBlock for:aProcess atMilliseconds:then. |
1724 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1734 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1735 ^ id |
|
1736 |
|
1737 "Modified: 23.9.1996 / 14:34:13 / cg" |
1725 ! |
1738 ! |
1726 |
1739 |
1727 addTimedBlock:aBlock for:aProcess afterSeconds:delta |
1740 addTimedBlock:aBlock for:aProcess afterSeconds:delta |
1728 "add the argument, aBlock to the list of time-scheduled-blocks. |
1741 "add the argument, aBlock to the list of time-scheduled-blocks. |
1729 to be evaluated after delta seconds. aProcess will be interrupted for |
1742 to be evaluated after delta seconds. aProcess will be interrupted for |
1731 (if it is running, the interrupt will occur in whatever method it is |
1744 (if it is running, the interrupt will occur in whatever method it is |
1732 executing; if it is suspended, it will be resumed). |
1745 executing; if it is suspended, it will be resumed). |
1733 If aProcess is nil, the block will be evaluated by the scheduler itself |
1746 If aProcess is nil, the block will be evaluated by the scheduler itself |
1734 (which is dangerous - the block should not raise any error conditions). |
1747 (which is dangerous - the block should not raise any error conditions). |
1735 The block will be removed from the timed-block list after evaluation |
1748 The block will be removed from the timed-block list after evaluation |
1736 (i.e. it will trigger only once)." |
1749 (i.e. it will trigger only once). |
1737 |
1750 Returns an ID, which can be used in #removeTimeoutWidthID:" |
1738 self addTimedBlock:aBlock for:aProcess afterMilliseconds:(delta * 1000) rounded |
1751 |
|
1752 ^ self addTimedBlock:aBlock for:aProcess afterMilliseconds:(delta * 1000) rounded |
|
1753 |
|
1754 "Modified: 23.9.1996 / 14:34:18 / cg" |
1739 ! |
1755 ! |
1740 |
1756 |
1741 addTimedBlock:aBlock for:aProcess atMilliseconds:aMillisecondTime |
1757 addTimedBlock:aBlock for:aProcess atMilliseconds:aMillisecondTime |
1742 "add the argument, aBlock to the list of time-scheduled-blocks; to be |
1758 "add the argument, aBlock to the list of time-scheduled-blocks; to be |
1743 evaluated by aProcess when the millisecondClock value passes |
1759 evaluated by aProcess when the millisecondClock value passes |
1750 (which is dangerous - the block should not raise any error conditions). |
1766 (which is dangerous - the block should not raise any error conditions). |
1751 If the process is active at trigger time, the interrupt will occur in |
1767 If the process is active at trigger time, the interrupt will occur in |
1752 whatever method it is executing; if suspended at trigger time, it will be |
1768 whatever method it is executing; if suspended at trigger time, it will be |
1753 resumed. |
1769 resumed. |
1754 The block will be removed from the timed-block list after evaluation |
1770 The block will be removed from the timed-block list after evaluation |
1755 (i.e. it will trigger only once)." |
1771 (i.e. it will trigger only once). |
|
1772 Returns an ID, which can be used in #removeTimeoutWidthID:" |
1756 |
1773 |
1757 |index "{ Class: SmallInteger }" |
1774 |index "{ Class: SmallInteger }" |
1758 wasBlocked| |
1775 wasBlocked| |
1759 |
1776 |
1760 wasBlocked := OperatingSystem blockInterrupts. |
1777 wasBlocked := OperatingSystem blockInterrupts. |
1761 index := timeoutActionArray identityIndexOf:aBlock startingAt:1. |
1778 index := timeoutActionArray identityIndexOf:aBlock startingAt:1. |
1762 index ~~ 0 ifTrue:[ |
1779 index ~~ 0 ifTrue:[ |
1763 timeoutArray at:index put:aMillisecondTime |
1780 timeoutArray at:index put:aMillisecondTime |
1764 ] ifFalse:[ |
1781 ] ifFalse:[ |
1765 index := timeoutArray indexOf:nil. |
1782 index := timeoutArray indexOf:nil. |
1766 index ~~ 0 ifTrue:[ |
1783 index ~~ 0 ifTrue:[ |
1767 timeoutArray at:index put:aMillisecondTime. |
1784 timeoutArray at:index put:aMillisecondTime. |
1768 timeoutActionArray at:index put:aBlock. |
1785 timeoutActionArray at:index put:aBlock. |
1769 timeoutSemaphoreArray at:index put:nil. |
1786 timeoutSemaphoreArray at:index put:nil. |
1770 timeoutProcessArray at:index put:aProcess |
1787 timeoutProcessArray at:index put:aProcess |
1771 ] ifFalse:[ |
1788 ] ifFalse:[ |
1772 timeoutArray := timeoutArray copyWith:aMillisecondTime. |
1789 timeoutArray := timeoutArray copyWith:aMillisecondTime. |
1773 timeoutActionArray := timeoutActionArray copyWith:aBlock. |
1790 timeoutActionArray := timeoutActionArray copyWith:aBlock. |
1774 timeoutSemaphoreArray := timeoutSemaphoreArray copyWith:nil. |
1791 timeoutSemaphoreArray := timeoutSemaphoreArray copyWith:nil. |
1775 timeoutProcessArray := timeoutProcessArray copyWith:aProcess. |
1792 timeoutProcessArray := timeoutProcessArray copyWith:aProcess. |
1776 ]. |
1793 index := timeoutArray size. |
|
1794 ]. |
1777 ]. |
1795 ]. |
1778 |
1796 |
1779 anyTimeouts := true. |
1797 anyTimeouts := true. |
1780 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1798 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1799 ^ index |
|
1800 |
|
1801 "Modified: 23.9.1996 / 14:34:23 / cg" |
|
1802 ! |
|
1803 |
|
1804 addTimeoutFunctionCall:anExternalFunction for:aProcess afterMilliseconds:delta with:argument |
|
1805 "prepare for an external function to be called with a single argument |
|
1806 after some millisecond-Delay. |
|
1807 If aProcess is nil, the block will be evaluated by the scheduler itself, |
|
1808 otherwise, that process will be interrupted and the function is performed |
|
1809 in this processes context. |
|
1810 The callBack will be removed from the timed-block list after evaluation |
|
1811 (i.e. it will trigger only once). |
|
1812 Returns an ID, which can be used in #removeTimeoutWidthID:" |
|
1813 |
|
1814 |now then wasBlocked id| |
|
1815 |
|
1816 wasBlocked := OperatingSystem blockInterrupts. |
|
1817 now := OperatingSystem getMillisecondTime. |
|
1818 then := OperatingSystem millisecondTimeAdd:now and:delta. |
|
1819 |
|
1820 id := self |
|
1821 addTimeoutFunctionCall:anExternalFunction |
|
1822 for:aProcess |
|
1823 atMilliseconds:delta |
|
1824 with:argument. |
|
1825 |
|
1826 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1827 ^ id |
|
1828 |
|
1829 "Created: 23.9.1996 / 14:28:27 / cg" |
|
1830 "Modified: 23.9.1996 / 14:34:42 / cg" |
|
1831 ! |
|
1832 |
|
1833 addTimeoutFunctionCall:anExternalFunction for:aProcess atMilliseconds:delta with:argument |
|
1834 "prepare for an external function to be called with a single argument |
|
1835 at some millisecond-time. |
|
1836 If aProcess is nil, the block will be evaluated by the scheduler itself, |
|
1837 otherwise, that process will be interrupted and the function is performed |
|
1838 in this processes context. |
|
1839 The callBack will be removed from the timed-block list after evaluation |
|
1840 (i.e. it will trigger only once). |
|
1841 Returns an ID, which can be used in #removeTimeoutWidthID:" |
|
1842 |
|
1843 |action| |
|
1844 |
|
1845 action := [anExternalFunction callWith:argument]. |
|
1846 ^ self |
|
1847 addTimedBlock:action |
|
1848 for:aProcess |
|
1849 atMilliseconds:delta. |
|
1850 |
|
1851 "Created: 23.9.1996 / 14:29:30 / cg" |
|
1852 "Modified: 23.9.1996 / 14:34:57 / cg" |
1781 ! |
1853 ! |
1782 |
1854 |
1783 evaluateTimeouts |
1855 evaluateTimeouts |
1784 "walk through timeouts and evaluate blocks or signal semas that need to be .." |
1856 "walk through timeouts and evaluate blocks or signal semas that need to be .." |
1785 |
1857 |
1853 timeoutActionArray at:index put:nil. |
1925 timeoutActionArray at:index put:nil. |
1854 timeoutSemaphoreArray at:index put:nil. |
1926 timeoutSemaphoreArray at:index put:nil. |
1855 timeoutProcessArray at:index put:nil. |
1927 timeoutProcessArray at:index put:nil. |
1856 ]. |
1928 ]. |
1857 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
1929 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1930 ! |
|
1931 |
|
1932 removeTimedBlockWithID:anID |
|
1933 "remove the timeOut with anID (as returned by #addTimedBlock) |
|
1934 from the list of time-sceduled-blocks." |
|
1935 |
|
1936 |index "{ Class: SmallInteger }" |
|
1937 wasBlocked| |
|
1938 |
|
1939 wasBlocked := OperatingSystem blockInterrupts. |
|
1940 index := anID. |
|
1941 (index ~~ 0) ifTrue:[ |
|
1942 timeoutArray at:index put:nil. |
|
1943 timeoutActionArray at:index put:nil. |
|
1944 timeoutSemaphoreArray at:index put:nil. |
|
1945 timeoutProcessArray at:index put:nil. |
|
1946 ]. |
|
1947 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
|
1948 |
|
1949 "Created: 23.9.1996 / 14:32:33 / cg" |
|
1950 "Modified: 23.9.1996 / 14:35:09 / cg" |
1858 ! ! |
1951 ! ! |
1859 |
1952 |
1860 !ProcessorScheduler methodsFor:'waiting'! |
1953 !ProcessorScheduler methodsFor:'waiting'! |
1861 |
1954 |
1862 checkForInputWithTimeout:millis |
1955 checkForInputWithTimeout:millis |