opennars / Narjure

A Clojure implementation of the Non-Axiomatic Reasoning System proposed by Pei Wang.
GNU General Public License v2.0
43 stars 11 forks source link

Blocking functions should not be called inside message handlers #25

Closed marotili closed 8 years ago

marotili commented 8 years ago

See https://github.com/puniverse/pulsar/issues/55 Since functions like call!, whereis, sleep or expensive functions will block the message handlers (and thus the message queue), they should not be run inside message handlers. Instead a fiber can be spawned that runs the blocking calls.

TonyLo1 commented 8 years ago

Generally agree with this. The design philosophy has been to only use non-blocking calls generally. The one exception to this has been the use of where-is in the initialisation handler. This is an optimisation. There is in fact a timeout version of whereis, that should probably be used in this case. Then it will not block (indefinitely)

I have specifically disallowed the use of call! in agents, only cast! is used.

patham9 commented 8 years ago

whereis is called on initialization of actors and the result put into the actor state for cast-calls in the message-handlers already it seems.