User Tools

Site Tools


notes:internals:db

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
notes:internals:db [2025/09/07 01:29] smj-edisonnotes:internals:db [2025/09/08 19:27] (current) smj-edison
Line 1: Line 1:
-====== Database ======+====== Database (folk2) ======
  
 //If you want to follow along in the code, all of these things are implemented in trie.c, db.c, folk.c, //If you want to follow along in the code, all of these things are implemented in trie.c, db.c, folk.c,
Line 39: Line 39:
   - We add "when" to the beginning, so the database knows this is a When.   - We add "when" to the beginning, so the database knows this is a When.
   - We preserve both the query and the code (that's the "the sky is /color/ { # code here }" part).   - We preserve both the query and the code (that's the "the sky is /color/ { # code here }" part).
-  - We add "with environment {foo bar}", as Tcl doesn't capture scopes. We manually capture the parent scope instead (containing the variable "foo" with the value of "bar"). We'll use this to execute the When later.+  - We add "with environment {foo bar}", as Tcl doesn't capture scopes. We manually capture the parent scope instead (containing the variable "foo" with the value of "bar"). We'll use this to execute the When later.
  
 ==== Reacting to Statements ==== ==== Reacting to Statements ====
Line 76: Line 76:
  
 === When scheduling === === When scheduling ===
-One exciting thing about folk2 is its support for multithreading. It does this by running each When +One exciting thing about folk2 is its support for multithreading. It supports this by scheduling each When 
-on its own thread. That means that when a Statement matches with a When, it needs to be queued for the next+to run on thread pool. That means that when a Statement matches with a When, it needs to be queued for the next
 available thread to pick it up. That's exactly what happened in this example. The Wish got inserted, available thread to pick it up. That's exactly what happened in this example. The Wish got inserted,
 it checked for matching Whens, and then when it found a match, it pushed it to the work queue to be run it checked for matching Whens, and then when it found a match, it pushed it to the work queue to be run
Line 164: Line 164:
 the last Term in `Wish $this has name "Mason Jones"` has spaces in it. It's just that in Tcl, lists are the last Term in `Wish $this has name "Mason Jones"` has spaces in it. It's just that in Tcl, lists are
 space seperated by default, and all the database commands are called from Tcl. space seperated by default, and all the database commands are called from Tcl.
 +
 +‡ This is simplified for explanation reasons. This is actually a list of environments, with each
 +entry being one level higher in the call stack.
notes/internals/db.1757208562.txt.gz · Last modified: by smj-edison

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki