Differences

This shows you the differences between the selected revision and the current version of the page.

at:tutorial:appendix 2020/02/05 20:57 at:tutorial:appendix 2020/04/28 19:47 current
Line 1: Line 1:
====== Appendix: Libraries ====== ====== Appendix: Libraries ======
-In the appendix, we explain useful libraries available to the AmbientTalk/2 programmer. These libraries provide abstractions ranging from traditional, established "collections" up to newly researched language constructs, such as "ambient references".+In the appendix, we explain useful libraries available to the AmbientTalk/2 programmer as part of the AmbientTalk standard library, also known as ''atlib''. These libraries provide abstractions ranging from traditional, established "collections" up to newly researched language constructs, such as "ambient references". 
 + 
 +The Ambientalk standard library (''atlib'') is part of the AmbientTalk/2 distribution. Note that the Intellij plugin already contains ''atlib''. If you would like to access the atlib source files, please visit the dedicated gitlab project [[ https://gitlab.soft.vub.ac.be/ambienttalk/atlib |here.]]
===== Unit Testing Framework ===== ===== Unit Testing Framework =====
Line 391: Line 393:
The files in the ''at/lang'' directory define custom language features which mostly use AmbientTalk/2's reflective facilities to extend the language. The files in the ''at/lang'' directory define custom language features which mostly use AmbientTalk/2's reflective facilities to extend the language.
 +
 +
Line 415: Line 419:
fut // return the future to a client fut // return the future to a client
</code> </code>
 +
 +The ''makeFuture'' function can also take a timeout. If a timeout is given it returns a returns a pair [lease, resolver]  where the lease timer gets immediately activated. If the future is not resolved within the given timeout, the lease expires and ruins the future with a ''TimeoutException''. Note that this means a lease will get parameter-passed rather than the future if given to other actors.
=== Auxilary functions in the futures module ==== === Auxilary functions in the futures module ====
Line 486: Line 492:
When the message sent to a multireference is annotated with @Due(t), the timeout is applied to the implicit multifuture, causing whenAll observers to trigger automatically. Note that the implicit multifuture of a multireference is bounded, so whenAll observers trigger automatically when all replies have been received. When the message sent to a multireference is annotated with @Due(t), the timeout is applied to the implicit multifuture, causing whenAll observers to trigger automatically. Note that the implicit multifuture of a multireference is bounded, so whenAll observers trigger automatically when all replies have been received.
 +
==== Leased Object References ==== ==== Leased Object References ====
Line 517: Line 524:
 +==== TOTAM ====
 +
 +The module ''/.at.lang.totam'' provides an implementation for TOTAM, a tuple space model geared towards mobile ad hoc networks which combines a replication-based tuple space model with a dynamic scoping mechanism that limits the transportation of tuples.
 +
 +Please have a look to [[:uf:totam]] for further details on the model and its API.
==== Dynamic Variables ==== ==== Dynamic Variables ====
Line 629: Line 641:
The files in the ''at/support'' subdirectory of the standard library implement various utilities of use to the AmbientTalk programmer. We discuss the most useful modules below. The files in the ''at/support'' subdirectory of the standard library implement various utilities of use to the AmbientTalk programmer. We discuss the most useful modules below.
 +
==== Timing Utilities ==== ==== Timing Utilities ====
Line 652: Line 665:
The timer module also defines a function ''whenever:elapsed:'' which repetitively invokes the given block closure every time the timeout period has elapsed. The returned subscription object can be used to eventually stop the repetitive invocation of the closure. The timer module also defines a function ''whenever:elapsed:'' which repetitively invokes the given block closure every time the timeout period has elapsed. The returned subscription object can be used to eventually stop the repetitive invocation of the closure.
-The timer module defines a small number of additional utility functions which can be found in the file ''at/support/timer.at''.+Finally, there is a variant of ''when:elapsed:'' called ''when:elapsedWithFuture:'' which returns a future that will be resolved or ruined by executing the given closure after the given timeout. This variant is very useful in unit tests, e.g: 
 + 
 +<code> 
 +def testAsyncNearbyPlayerReply(){ 
 +  def nearbyPlayers := // search 2 nearby player orjbects; 
 +  // wait a bit so that there are the 2 members. 
 +  when: 2.seconds elapsedWithFuture:{ 
 + self.assertEquals(2, nearbyPlayers.getReceivedAnswers); 
 +  } 
 +}; 
 +</code> 
==== Logging Framework ==== ==== Logging Framework ====
 
 
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki