KnowledgeWorks and Prolog User Guide > 6 Advanced Topics > 6.5 Inferencing States > 6.5.3 Uses of Inferencing States

NextPrevUpTopContentsIndex

6.5.3.2 Interleaved in a Single Thread

By binding *inferencing-state* around specific KnowledgeWorks operations in a function as in the example below, multiple inferencing states can be maintained within a single thread.

(defun test-stepping-single-context ()
  (let ((state1 (make-inferencing-state 'state1))
        (state2 (make-inferencing-state 'state2)))
    (unwind-protect
        (progn
          (let ((*inferencing-state* state1))
            (make-instance 'step-controller
                           :kb-name 'stepper-one-a))
          (let ((*inferencing-state* state2))
            (make-instance 'step-controller
                           :kb-name 'stepper-one-b))
          (loop repeat 10
                do
                (let ((*inferencing-state* state1))
                  (infer))
                (let ((*inferencing-state* state2))
                  (infer))))
      (destroy-inferencing-state state1)
      (destroy-inferencing-state state2))))

 


KnowledgeWorks and Prolog User Guide (Windows version) - 22 Dec 2009

NextPrevUpTopContentsIndex