Master Worker
From Indus Communities
The Master Worker style of coordination may represent a single or a chain of calls from client programs to server side programs in an asynchronous fashion. It is the asynchronous equivalent of the existing synchronous 'call and return' style of coordination.
A Master Worker call syntax is similar to the 'call and return' syntax.
Syntax :
agent | component.method( )
where,
- agent or component refers to an instance of type Agent or Component
Any invocation of a method declared in an Agent or Component definition automatically qualifies for a Master Worker call by a client.
public Agent MasterAgent
{
public void setValue(int x);
public int getValue();
public void incrValue();
}
Definition file : MasterAgent.indus
public class Master implements MasterAgent
{
Context{
setServantType("USER");
}
public int m_value = 0;
public int getValue()
{
return m_value;
}
public void setValue(int v)
{
m_value = v;
}
public void incrValue()
{
m_value++;
}
public static void main(String [] args)
{
try
{
Master m = newType Master("mh1");
int value = m.getValue();
// First Master Worker call
System.out.println("value = " + value);
m.setValue(100);
value = m.getValue();
// Second Master Worker call
System.out.println("value = " + value);
m.incrValue();
value = m.getValue();
System.out.println("value = " + value);
m.incrValue();
value = m.getValue();
System.out.println("value = " + value);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Implementation file : Master.indus
Syntactic sugar is applied over the Master Worker style to derive other forms of coordination in Indus.
