Changeset dc136d7 for doc/theses/colby_parsons_MMAth
- Timestamp:
- Jun 19, 2023, 10:53:21 AM (17 months ago)
- Branches:
- master
- Children:
- 2c38b15, ca0c311
- Parents:
- 6d18ddb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/colby_parsons_MMAth/text/actors.tex
r6d18ddb rdc136d7 283 283 \subsection{Actor Send}\label{s:ActorSend} 284 284 All message sends are done using the vertical-bar (bit-or) operator, @?|?@, similar to the syntax of the \CFA stream I/O. 285 Hence, programmers must write a matching @?|?@ routine for each @receive@ routine, which is awkward and generates a maintenance problem That must be solved. 286 The currently supported approach to creating a generic @?|?@ routine requires users to create specific routines for their actor and message types that access the base type. 287 Since these routines are not complex, they can be generated using macros that the user can add following their message and actor types. 288 This works, but is not much better than asking users to write the @?|?@ routine themselves. 285 Hence, programmers must write a matching @?|?@ routine for each @receive@ routine, which is awkward and generates a maintenance problem that must be solved. 286 \CFA's current best approach for creating a generic @?|?@ routine requires users to create routines for their actor and message types that access the base type. 287 Since these routines are not complex, they can be generated using macros that are used to annotate the user-defined actor and message types. 288 This approach is used in \CFA's intrusive list data structure. 289 This is not much better than asking users to write the @?|?@ routine themselves in terms of maintenance, since the user needs to remember the boilerplate macro annotation. 289 290 290 291 As stated, \CFA does not have named inheritance with RTTI. 291 292 \CFA does have a preliminary form of virtual routines, but it is not mature enough for use in this work. 292 Virtuals would provide a clean mechanism to write a single generic @?|?@ routine taking a base actor and message type, and then dynamically selectingthe @receive@ routine from the actor argument.293 Virtuals would provide a mechanism to write a single generic @?|?@ routine taking a base actor and message type, that would dynamically select the @receive@ routine from the actor argument. 293 294 Note, virtuals are not needed for the send; Plan-9 inheritance is sufficient because only the inherited fields are needed during the message send (only upcasting is needed). 294 295 … … 324 325 325 326 \subsection{Actor Termination}\label{s:ActorTerm} 326 As discussed in Section~\ref{s:ActorSend}, during a message send, the derived type of the actor and message is erased, and then recovered later by calling the receive routine. 327 During a message send, the receiving actor and message being sent are stored via pointers in the envelope. 328 These pointers have the base actor and message types, so type information of the actor and message is lost and then recovered later when the typed receive routine is called. 327 329 After the receive routine is done, the executor must clean up the actor and message according to their allocation status. 328 330 If the allocation status is @Delete@ or @Destroy@, the appropriate destructor must be called by the executor. 329 This poses a problem; the type of the actor or message is not available to the executor, but it needs to call the right destructor!330 This requires down -casting from the base type to derived type, which requires a virtual system.331 This poses a problem; the correct type of the actor or message is not available to the executor, but it needs to call the right destructor! 332 This requires downcasting from the base type to derived type, which requires a virtual system. 331 333 Thus, a rudimentary destructor-only virtual system was added to \CFA as part of this work. 332 This virtual system is used via Plan-9 inheritance of the @virtual_dtor@ type .334 This virtual system is used via Plan-9 inheritance of the @virtual_dtor@ type, shown in Figure~\ref{f:VirtDtor}. 333 335 The @virtual_dtor@ type maintains a pointer to the start of the object, and a pointer to the correct destructor. 334 When a type inherits the @virtual_dtor@ type, the compiler adds code to its destructor to make sure that whenever any destructor along inheritance tree is called, the destructor call is intercepted, and restartsat the appropriate destructor for that object.336 When a type inherits the @virtual_dtor@ type, the compiler adds code to its destructor to make sure that any destructor calls along this segment of the inheritance tree is called are intercepted, and restart at the appropriate destructor for that object. 335 337 336 338 \begin{figure} … … 344 346 intermediate_type & i = d2; 345 347 base_type & b = d3; 346 ^d1{}; ^i{}; ^b{}; // all of these will call the destructors in the correct order 348 349 // these will call the destructors in the correct order 350 ^d1{}; ^i{}; ^b{}; 347 351 } 348 352
Note: See TracChangeset
for help on using the changeset viewer.