X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=doc%2F8sync.texi;h=7412ea1e75942a11cdf532ddaa51f8a221830a95;hb=266a8f61a5fe151a9718feebdbb0b3d74465f6e2;hp=1d9e4af0c5f457b3aea06db974b507dd2e932cd4;hpb=cc21b6de963deb90a0b167a456378d4cc355e89c;p=8sync.git diff --git a/doc/8sync.texi b/doc/8sync.texi index 1d9e4af..7412ea1 100644 --- a/doc/8sync.texi +++ b/doc/8sync.texi @@ -440,8 +440,9 @@ How about an actor that start sleeping, and keeps sleeping? (define-class () (actions #:allocation #:each-subclass - #:init-value (build-actions - (*init* sleeper-loop)))) + #:init-thunk (build-actions + (*init* sleeper-loop))) + (sleep-secs #:init-value 1 #:getter sleeper-sleep-secs)) (define (sleeper-loop actor message) (while (actor-alive? actor) @@ -457,9 +458,12 @@ How about an actor that start sleeping, and keeps sleeping? We see some particular things in this example. One thing is that our @verb{~~} actor has an actions slot. This is used to look up what the "action handler" for a message is. -We have to set the #:allocation to either @verb{~#:each-subclass~} or -@verb{~#:class~}.@footnote{#:class should be fine, except there is @uref{https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25211,a bug in Guile} which keeps -us from using it for now.} +We have to set the #:allocation to either @verb{~#:each-subclass~} +and use @verb{~#:init-thunk~}.@footnote{@verb{~build-subclass~} returns +a thunk to be called later so that each subclass may correctly build +its own instance. This is important because the structure returned +contains a cache, which may vary from subclass to subclass based on +its inheritance structure.} The only action handler we've added is for @verb{~*init*~}, which is called implicitly when the actor first starts up.