Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #14389
| From | krishna.myneni@ccreweb.org |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Non-blocking asynchronous execution |
| Date | 2012-07-25 16:57 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <7cb18bba-fb1b-4e2b-bc0b-74e56bae0d91@googlegroups.com> (permalink) |
| References | <jup4k8$u1a$1@dont-email.me> |
On Wednesday, July 25, 2012 10:50:32 AM UTC-5, Arnold Doray wrote:
> Dear Forthers,
>
> I came across this interesting talk recently:
>
> http://www.youtube.com/watch?v=jo_B4LTHi3I
>
> One thing that interested me in the talk is node.js' non-blocking,
> asynchronous execution model without using threads. I believe Erlang uses
> something like this. How would you accomplish it using your Forth? Eg,
>
> : set-timeout ( xtCallback timeMillisec -- ) ... ;
>
> : greeting ." Hello World " . ;
> : greeting2 ." Goodbye World " . ;
>
> ' greeting 5000 set-timeout
> greeting2
>
> Goodbye World ok <-- occurs immediately
> Hello World ok <-- occurs after 5 seconds have elapsed.
>
> Ie, SET-TIMEOUT schedules its callback for execution at the predefined
> time interval without blocking.
>
> Cheers,
> Arnold
Below is one way to do it in kForth, using POSIX signals.
Krishna
--
\ Example of Asynchronous Delayed Execution in kForth
\ Using POSIX signals.
include signal
variable xtDelay
: delayed-word ( -- )
xtDelay @ execute
SIG_IGN SIGALRM forth-signal DROP \ Stop sending SIGALRM
;
: set-timeout ( xtCallback timeMillisec -- )
swap xtDelay !
['] delayed-word SIGALRM forth-signal drop
dup SET-TIMER \ Send SIGALRM to kForth at specified interval
;
: greeting ." Hello World" ;
: greeting2 ." Goodbye World" ;
' greeting 5000 set-timeout
greeting2
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-25 15:50 +0000
Re: Non-blocking asynchronous execution Mark Wills <markrobertwills@yahoo.co.uk> - 2012-07-25 09:09 -0700
Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-26 02:48 +0000
Re: Non-blocking asynchronous execution rickman <gnuarm@gmail.com> - 2012-07-25 14:41 -0700
Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-26 02:54 +0000
Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-25 20:48 -0700
Re: Non-blocking asynchronous execution krishna.myneni@ccreweb.org - 2012-07-25 16:57 -0700
Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-25 17:22 -0700
Re: Non-blocking asynchronous execution krishna.myneni@ccreweb.org - 2012-07-25 18:22 -0700
Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-26 03:03 +0000
Re: Non-blocking asynchronous execution krishna.myneni@ccreweb.org - 2012-07-26 00:59 -0700
Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-26 08:27 +0000
Re: Non-blocking asynchronous execution krishna.myneni@ccreweb.org - 2012-07-26 11:02 -0700
Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-27 05:09 +0000
Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-27 00:03 -0700
Re: Non-blocking asynchronous execution Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-27 11:55 +0000
Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-25 17:48 -0700
Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-26 02:44 +0000
Re: Non-blocking asynchronous execution "Elizabeth D. Rather" <erather@forth.com> - 2012-07-25 17:26 -1000
Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-27 05:23 +0000
Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-26 23:24 -0700
Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-25 20:56 -0700
Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-26 08:21 +0000
Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-26 13:43 -0700
Re: Non-blocking asynchronous execution Arnold Doray <invalid@invalid.com> - 2012-07-27 04:40 +0000
Re: Non-blocking asynchronous execution Paul Rubin <no.email@nospam.invalid> - 2012-07-26 23:10 -0700
Re: Non-blocking asynchronous execution jim@rainbarrel.com - 2012-07-27 10:41 -0700
csiph-web