-
Notifications
You must be signed in to change notification settings - Fork 2
languageguide
HS was designed to do client/server (or query/reply) in a synchronous manner.
So for example, if you need to perform several queries in a row, where the order is important...
ret = query ( "target1/location1", "HELLO" ) ;
// Do something important
ret = query ( "target2/location2", "GREETING" ) ;
// Do something next
ret = query ( "target2@location3", "GUTENTAG" ) ;
// Continue to process now that all queries have come in
...then during any of the queries (i.e. while in a QUERY state), HS can service other incoming requests, or it can be executing other methods in the context of another instance.
// Create a worker instance and set it going
instance "worker" ;
event ( "worker#"+self(2), "DO_WORK" ) ;
In contrast, using a language such as JAVASCRIPT, you must perform the queries asynchronously and respond to callbacks. This requires you to programmatically track the state of the queries, to know which have come in and which are still pending. In an automation environment, this can be tricky. When state transitions are built right into the language, the program never gets out-of-sync because it is written in a synchronous way.