w3c / cogai

for work by the Cognitive AI community group
Other
55 stars 25 forks source link

Priority Queues #4

Open draggett opened 4 years ago

draggett commented 4 years ago

In a real-time environment, events can be notified by setting the goal module's buffer. If two processes independently set the goal buffer in a very short time interval, the first event will be overwritten before the rule engine has a chance to respond to it. To avoid this, the rule engine supports a priority queue for module buffers. Chunks can be pushed to the queue and are placed in the queue according to their priority. The priority is not exposed in the rule language. The rule engine pops the queue after executing a rule provided that none of the actions in that rule explicitly updated the buffer. In the JavaScript library (chunks.js) the priority is an integer in the range 1 to 10 with 1 as the lowest priority and 10 the highest.

draggett commented 4 years ago

You can clear the module's buffer with "@do clear" or pop its queue with "@do pop". A further option is to undefine a property of the module's buffer with "@undefine foo" for property foo. This has no effect if that property is already undefined. Note @do should have a lower case "D" but GitHub is rendering this incorrectly.