Пример #1
0
    def __init__(self,endpoint_a,*args):
        test_util.DummyEndpoint.__init__(self,*args)

        self.endpoint_a = endpoint_a
        
        setattr(
            self,
            util.partner_endpoint_msg_call_func_name('receive_message_for_a'),
            self.receive_message_for_a)
    def __init__(self,conn_obj):
        test_util.DummyEndpoint.__init__(self,conn_obj)

        # when dispatching to partner, we request the function name as
        # it would appear in the Waldo source file.  However, the
        # compiler mangles it into another name.  The call below
        # ensures that that the mangled name exists.
        setattr(
            self,
            util.partner_endpoint_msg_call_func_name('sequence_block'),
            self.sequence_block)
Пример #3
0
    def __init__(self,*args):
        test_util.DummyEndpoint.__init__(self,*args)

        # adding data for b
        self.beta_name = 'beta'
        self._global_var_store.add_var(
            self.beta_name,
            wVariables.WaldoNumVariable(
                self.beta_name,self._host_uuid,
                False,1))
        setattr(
            self,
            util.endpoint_call_func_name('update_beta'),
            self.update_beta)
        setattr(
            self,
            util.partner_endpoint_msg_call_func_name('update_beta_when_receive_message'),
            self.update_beta_when_receive_message)
Пример #4
0
def emit_message_receive(
    message_receive_node,next_to_call_node,endpoint_name,ast_root,
    fdep_dict,emit_ctx):
    '''
    @param {AstNode or None} next_to_call_node --- If AstNode, then
    has label AST_MESSAGE_RECEIVE_FUNCTION.  If None, means that this
    is the last message receive node in sequence and should tell other
    side to issue a block call with target None.
    '''

    msg_recv_node_name_node = message_receive_node.children[1]
    msg_recv_name = msg_recv_node_name_node.value
    
    emit_ctx.in_message_receive = True
    emit_ctx.message_seq_return_txt = '\nreturn '

    msg_receive_txt = emit_private_method_interface(
        message_receive_node,endpoint_name,ast_root,fdep_dict,emit_ctx,
        lib_util.partner_endpoint_msg_call_func_name)
    msg_receive_txt += '\n'
    
    emit_ctx.in_message_receive = False
    emit_ctx.message_seq_return_txt = ''

    ## Ends by telling the opposite side what to do next
    next_to_call_txt = 'None'
    if next_to_call_node != None:
        # the name of the next sequence block to execute, as it
        # appears in the source Waldo text, ie, before mangling.
        next_sequence_block_src_name = next_to_call_node.children[1].value
        
        next_to_call_txt = '"' + lib_util.partner_endpoint_msg_call_func_name(
            next_sequence_block_src_name) + '"'
        

        
    # note that we must wait on receiving a response from the other
    # side before we can continue on, or the original sender may
    # return too early. We should not wait on the last message that we
    # send however, because, we do not expect any response to it.
    # (Ie, if next_to_call_txt == 'None', then do not wait.)
    next_sequence_txt = '''

_threadsafe_queue = %s.Queue()
_active_event.issue_partner_sequence_block_call(
    _context,%s,_threadsafe_queue,False)
# must wait on the result of the call before returning

if %s != None:
    # means that we have another sequence item to execute next

    _queue_elem = _threadsafe_queue.get()


''' % (emit_utils.library_transform('Queue'),
       next_to_call_txt,
       next_to_call_txt)



    next_sequence_txt += '''

    if isinstance(_queue_elem,%s):
        # back everything out
        raise %s()

    _context.set_to_reply_with(_queue_elem.reply_with_msg_field)

    # apply changes to sequence variables.  Note: that
    # the system has already applied deltas for global data.
    _context.sequence_local_store.incorporate_deltas(
        _active_event,_queue_elem.sequence_local_var_store_deltas)

    # send more messages
    _to_exec_next = _queue_elem.to_exec_next_name_msg_field
    if _to_exec_next != None:
        # means that we do not have any additional functions to exec
        _to_exec = getattr(self,_to_exec_next)
        _to_exec(_active_event,_context)

''' % (emit_utils.library_transform('BackoutBeforeReceiveMessageResult'),
       emit_utils.library_transform('BackoutException'))


    msg_receive_txt += emit_utils.indent_str(next_sequence_txt)
    return msg_receive_txt