User Tools

Site Tools


at:tutorial:appendix

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
at:tutorial:appendix [2020/02/05 21:00] – adding elisagat:tutorial:appendix [2020/04/28 19:44] – adding elisag
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 417: Line 420:
 </code> </code>
  
-''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. Note that this means a lease will get parameter-passed rather than the future if given to other actors.+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 489: 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 518: Line 522:
 Finally, the ''leasedrefs'' module exports support primitives to manipulate time intervals (i.e. ''minutes'', ''seconds'', ''millisecs'') so that developers do not need to explicitly import the timer module to use leased references. Finally, the ''leasedrefs'' module exports support primitives to manipulate time intervals (i.e. ''minutes'', ''seconds'', ''millisecs'') so that developers do not need to explicitly import the timer module to use leased references.
  
 +
 +==== TOTAM ====
 +
 +The module ''/.at.lang.totam'' provides support for communication using.
 +
 +Please have a look to [[:uf:totam]] for further details.
  
  
Line 632: Line 642:
  
 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 655: Line 666:
 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 small number of additional utility functions which can be found in the file ''at/support/timer.at''.+Finally, there is 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 ====
at/tutorial/appendix.txt · Last modified: 2021/09/24 10:28 by elisag