The term semphore is derived from the old military flag signalling used to coordinate troops over long distances (prior to the advent of telecommunications). The idea is that if every squad or platoon had "roles" or "rules" as to what they were supposed to do, simple flag signals could be used to mobilize or halt these units with respect to executing their operation.
For example, if the plan was to execute a three-pronged attack against the enemy at first light, the concept is very good, but the problem is that to three different locales on the battle field, first light could be a difference of 5 or 10 minutes. However, if the instructions were execute your attack at dawn and precisely when you receive the flag signal, then there is no question. Rules are like the squads in the military -- they execute when the conditions are met. Basically a semaphore (usually a binary object, but that is not the only form a semphore can take) is used to say wait until this condition is met and this condition can only be met when the command-center has issued it. Alternately, you can consider the control of a train switch (or any switch). When a signal to switch the tracks is issued, the logical step would be to switch the tracks. However, this cannot be executed when there is a train on that segment. A semaphore could be used to maintain the knowledge of the presence of a train on that segment of the tracks (train_present = true). When the train passes, another rule changes the state of the "train_present" semaphore (train_present = false). The rule to switch the tracks can only fire if the command token has been received (command_token = "change tracks") and the semaphore "train_present" is false! Hope this helps. - Dave -----Original Message----- From: Anagha [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 16, 2005 4:52 AM To: [email protected] Subject: [drools-user] Semaphore Example Hi, Can anybody explain the use of semaphore with drools by a simple example? Drools home page expains it as "Semaphore provides global named variables and can be used to control execution". What is its exact use inside <parameter> element? Any help is appreciated. Thanks & Regards, Anagha
