Erlang (programming language)/Tutorials/Timeouts: Difference between revisions
imported>Eric Evers (New page: =Timeouts= Timeouts are created by the [ receive - after - end ] structure. Timeouts are measured in miliseconds so 4000 = 4 seconds. We can create a simple timer with the following progr...) |
imported>Tom Morris m (Erlang programming language/Tutorials/Timeouts moved to Erlang (programming language)/Tutorials/Timeouts) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{subpages}} | |||
=Timeouts= | =Timeouts= | ||
Line 23: | Line 25: | ||
% 9> myTimer:start(4000). | % 9> myTimer:start(4000). | ||
% your 4.00000 secs are up.ok | % your 4.00000 secs are up.ok | ||
The atom: | |||
infinity | |||
is a valid value for a timeout and causes an infinite wait. |
Latest revision as of 06:07, 8 August 2009
The metadata subpage is missing. You can start it via filling in this form or by following the instructions that come up after clicking on the [show] link to the right. | |||
---|---|---|---|
|
Timeouts
Timeouts are created by the [ receive - after - end ] structure. Timeouts are measured in miliseconds so 4000 = 4 seconds. We can create a simple timer with the following program: myTimer.erl
% ============================================================ >% -module( myTimer ). -compile( export_all ). % % A simple timer that uses a timeout. % start( Timeout ) -> receive after Timeout -> io:format( "your ~w secs are up." , [Timeout/1000] ) end. % ============================================================ >% % % Sample output: % % 8> c(myTimer). % ok. % % 9> myTimer:start(4000). % your 4.00000 secs are up.ok
The atom:
infinity
is a valid value for a timeout and causes an infinite wait.