From OpenCog
Jump to: navigation, search

The SleepLink is a kind of FunctionLink that, when executed, will first execute its outgoing set, which should result in a NumberNode, and then use the value of the NumberNode to sleep the current thread for that many seconds. The result of execution is a NumberNode holding how many seconds remain for the sleep (currently zero, unless the thread is interrupted by some outside mechanism).

It only makes sense to use this link in it's own thread; you don't want to block whatever thread you are interacting in. New threads can be created with ParallelLink and JoinLink.

Example usage:

(use-modules (opencog) (opencog exec))
(cog-execute! (SleepLink (PlusLink (NumberNode 1) (NumberNode 2))))

The above will sleep the current thread for three seconds.

See also