Skip to content

Commit

Permalink
[core] Rename "receive()" to "willReceive()".
Browse files Browse the repository at this point in the history
close #409

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Sep 2, 2016
1 parent 66684ca commit 1484d56
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
21 changes: 21 additions & 0 deletions eclipse-sarl/plugins/io.sarl.core/src/io/sarl/core/bic.sarl
Expand Up @@ -419,9 +419,30 @@ capacity DefaultContextInteractions {
* ...
* MyAgent.spawn(mySpawnArgs).receive(new StartWorkingEvent)
* </code>
*
* @Deprecated see #willReceive(UUID, Event)
*/
@Deprecated
def receive(receiver : UUID, e : Event)

/**
* Inverse signature of send. Useful to send events using the agent's UUID.
* Example:
* If you need to send an event to a newly created agent you should usually do :
* <code>
* ...
* const mySpawnArgs = ...
* const myAgentAddr = MyAgent.spawn(mySpawnArgs)
* defaultSpace.emit(new StartWorkingEvent, AddressScope::scope(myAgentAddr)
* </code>
* <p>The equivalent using receive could be written:
* <code>
* ...
* MyAgent.spawn(mySpawnArgs).willReceive(new StartWorkingEvent)
* </code>
*/
def willReceive(receiver : UUID, e : Event)

/** Replies if the given space is the default space of the default context.
*
* @param space - the space to test.
Expand Down
Expand Up @@ -108,8 +108,17 @@ public EventSpace getDefaultSpace() {
return this.defaultSpace;
}

/** {@inheritDoc}
* @deprecated see {@link #willReceive(UUID, Event)}
*/
@Deprecated
@Override
public void receive(UUID receiverID, Event event) {
willReceive(receiverID, event);
}

@Override
public void willReceive(UUID receiverID, Event event) {
final Address recAddr = this.defaultSpace.getAddress(receiverID);
this.emit(event, Scopes.addresses(recAddr));
}
Expand Down

0 comments on commit 1484d56

Please sign in to comment.