Ignore:
Timestamp:
Jun 19, 2023, 10:53:21 AM (16 months ago)
Author:
caparsons <caparson@…>
Branches:
master
Children:
2c38b15, ca0c311
Parents:
6d18ddb
Message:

cleaned up actor send/terminate sections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/colby_parsons_MMAth/text/actors.tex

    r6d18ddb rdc136d7  
    283283\subsection{Actor Send}\label{s:ActorSend}
    284284All 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.
     285Hence, 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.
     287Since these routines are not complex, they can be generated using macros that are used to annotate the user-defined actor and message types.
     288This approach is used in \CFA's intrusive list data structure.
     289This 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.
    289290
    290291As stated, \CFA does not have named inheritance with RTTI.
    291292\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 selecting the @receive@ routine from the actor argument.
     293Virtuals 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.
    293294Note, 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).
    294295
     
    324325
    325326\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.
     327During a message send, the receiving actor and message being sent are stored via pointers in the envelope.
     328These 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.
    327329After the receive routine is done, the executor must clean up the actor and message according to their allocation status.
    328330If 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.
     331This 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!
     332This requires downcasting from the base type to derived type, which requires a virtual system.
    331333Thus, 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.
     334This virtual system is used via Plan-9 inheritance of the @virtual_dtor@ type, shown in Figure~\ref{f:VirtDtor}.
    333335The @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 restarts at the appropriate destructor for that object.
     336When 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.
    335337
    336338\begin{figure}
     
    344346    intermediate_type & i = d2;
    345347    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{};
    347351}
    348352
Note: See TracChangeset for help on using the changeset viewer.