• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ receive_message函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中receive_message函数的典型用法代码示例。如果您正苦于以下问题:C++ receive_message函数的具体用法?C++ receive_message怎么用?C++ receive_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了receive_message函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: procA

void procA ()
{
	//receive the message envelope from CCI when user types in 's'
	//then deallocate the received message envelope
	ps("1");
	MsgEnv *init_msg = (MsgEnv*)receive_message();

	while (init_msg==NULL) {
		init_msg = (MsgEnv*)receive_message();
	}
	release_message_env(init_msg);
	ps("2");

	//initialize counter
	int num_count = 0;

	//loop forever
	while(1)
	{
		//request a message envelope, and set the type to COUNT_REPORT
		//set the data field of the msg env equal to the counter
		MsgEnv *toB = (MsgEnv*)request_msg_env();
		toB->msg_type = COUNT_REPORT;
		toB->data[0] = (char)num_count;
		toB->data[1] = '\0';

		//send the message envelope to B
		//increment the counter and yield the processor to other processes
		send_message(PROCB_ID, toB);
		num_count++;
		ps("test2");
		release_processor();
	}
}
开发者ID:y36ding,项目名称:Barby1,代码行数:34,代码来源:procABC.c


示例2: proc2

//Test 1 reciever (message can be accurately sent/recieved)
void proc2(void) {
    int pid = 2;
    int sender = 1;
    msgbuf *msg;
    
    msg = receive_message(&sender);
    
    //check message contents
    if (msg->mtype == DEFAULT && msg->mtext[0] == MSG_TEXT_1){
        test_status[0] = TEST_SUCCESS;//TEST 1: Message contents same as when sent
    } else {
        test_status[0] = TEST_FAILURE;//message contents incorrect
    }
    
    release_memory_block(msg);
    
    //Done testing
    set_process_priority(pid, LOWEST);

#ifdef _DEBUG_HOTKEYS
    // Force this process to be BLOCKED_ON_RECEIVE
    receive_message(NULL);
#endif // _DEBUG_HOTKEYS

    while (1) {
        release_processor();
    }
}
开发者ID:hjarmstrong,项目名称:se350-1,代码行数:29,代码来源:test_procs_p2.c


示例3: main

int main () {
    int socket_desc = init();
    
    
    char *message = "GET /var/14 HTTP/1.1\r\nHost:pb-homework.appspot.com\r\n\r\n";
    send_message(socket_desc, message);
    
    
    char server_reply[2000];
    receive_message(server_reply, socket_desc);
   
    
    char *secret_ptr = strstr(server_reply, "secret=");
    char *message2=malloc(sizeof(char)*100);
    sprintf(message2, "GET /var/14?%s HTTP/1.1\r\nHost:pb-homework.appspot.com\r\n\r\n", secret_ptr);
    message=message2;
    
    send_message(socket_desc, message);
    receive_message(server_reply, socket_desc);
    
    
    int result = count_result(server_reply);
    
    char *message3=malloc(sizeof(char)*100);
    sprintf(message3, "POST /var/14 HTTP/1.1\r\nHost:pb-homework.appspot.com\r\nContent-length: 8\r\n\r\nresult=%d", result);
    message=message3;
    
    
    send_message(socket_desc, message);
    receive_message(server_reply, socket_desc);
    
    close(socket_desc);
}
开发者ID:AlexandraPV,项目名称:Repository,代码行数:33,代码来源:client.c


示例4: receive

    /** Receive data.
      *
      * \warning You should not rely on receiving a single specific data element 
      *          with the fast_client and fast_server implementation. Expect data to get lost.
      *
      * \param [in,out] t data to be received
      * \param [in] timeout_ms Maximum wait time in milliseconds to receive data.
      *             Timeout is set to 1 second by default.
      * \returns true if data was received successfully.
      * \returns false when receive timeout occurred.
      * \throws ib_error on error
      */
    virtual bool receive(T &t, int timeout_ms = 1000)
    {
      IB_ASSERT(network_entity::_s, ib_error::EINVALIDSOCKET);

      io::ensure_cleanup_partial_messages ecpm(this->get_socket());

      const bool has_wait = (timeout_ms != 0);
      const int max_skip = _enable_skip ? _recv_skip : 0;
      int k = max_skip;
       
      bool has_data = false;
      while (k >= 0 && receive_message(t, ZMQ_DONTWAIT)) {
        --k;
      }

      // Received at least one message from queue.
      if (k != max_skip) {
          return true;
      }

      // We haven't received anything. See if waiting is ok.
      if (has_wait && io::is_data_pending(*network_entity::_s, timeout_ms)) {
        receive_message(t, 0);
        return true;
      } else {
        return false;
      }

    }
开发者ID:rickesh,项目名称:image-babble,代码行数:41,代码来源:fast.hpp


示例5: proc1

//TC 1: Delayed message sending & no preemption 
void proc1(void) {	
	MSG_BUF* envelope = NULL;
	char* msg = "SE 350";
	
	uart1_put_string("\n\r");
	uart1_put_string("G003_test: START\n\r");
	uart1_put_string("G003_test: total ");
	uart1_put_char(total + 48);
	uart1_put_string(" tests\n\r");
	
	prev_pid = 1;
	
	envelope = (MSG_BUF*)request_memory_block();

	strcpy(envelope->mtext, msg);
	delayed_send(1, envelope, 5000);
	envelope = (MSG_BUF*)receive_message(NULL);

	if (strcmp(envelope->mtext, msg) == 0) {
		prev_success = 1;
	} else {
		prev_success = 0;
	}

	release_memory_block(envelope);

	if (prev_success) {
		uart1_put_string("G003_test: test ");
		uart1_put_char(1 + 48);
		uart1_put_string(" OK\n\r");
		pass = pass + 1;
	} else {
		uart1_put_string("G003_test: test ");
		uart1_put_char(1 + 48);
		uart1_put_string(" FAIL\n\r");
	}

	//TC 2: Blocked on receive & preemption
	envelope = (MSG_BUF*)receive_message(NULL);

	prev_success = 1;  // Checks if you ever get here.

	release_memory_block(envelope);

	if (prev_success) {
		uart1_put_string("G003_test: test ");
		uart1_put_char(2 + 48);
		uart1_put_string(" OK\n\r");
		pass = pass + 1;
	} else {
		uart1_put_string("G003_test: test ");
		uart1_put_char(2 + 48);
		uart1_put_string(" FAIL\n\r");
	}

	while (1) {
		release_processor(); 
	}	
}
开发者ID:jerryzxliu,项目名称:se350lab,代码行数:60,代码来源:test_p2.c


示例6: segment_display

// display thread handler
void segment_display(void const * arg){
	uint16_t LED_pins[4] = { GPIO_Pin_12, GPIO_Pin_13, GPIO_Pin_14, GPIO_Pin_15 };
	int count = 0;
	char key = DUMMY_KEY, led = '1';
	int mode = TEMP_MODE;
	float temperature = 50.0;
	float pitch = 0.0;
		
	display_init();
	
	float data; 
	
	while(1){
		osSignalWait(DISPLAY_READY, osWaitForever);
				
		// try to get the keypad message		
		if (receive_message(&data, keypad_queue)){
			key = (char)(((int)data) + '0');
			
			// figure out which type of key was pressed (i.e. mode or led) and adjust variables accordingly. 
			if (key == TEMP_MODE_KEY || key == MEMS_MODE_KEY){
				mode = key == TEMP_MODE_KEY ? TEMP_MODE : MEMS_MODE;
			} else {
				led = key;
			}			
		}
		
		// try to get the pitch message
		if (receive_message(&data, pitch_queue)){
			pitch = data;
		}
		
		// try to get the temperature message
		if (receive_message(&data, temp_queue)){
			temperature = data;
		}
				
		GPIO_ResetBits(GPIOD, GPIO_SEGMENT_PINS);
		GPIO_ResetBits(GPIOE, GPIO_DIGIT_SELECT_PINS);
	
		// run the display effect depending on whether or not an alarm is triggerd and the type of mode.
		if (temperature < ALARM_THRESHOLD || (count % (2 * TIM3_DESIRED_RATE)) < TIM3_DESIRED_RATE) {		
			if (mode == TEMP_MODE){
				GPIO_ResetBits(GPIOD, ALL_LED_PINS);
				display_value(temperature, count, TEMP_MODE); 
			} else {
				display_value(pitch, count, MEMS_MODE);
			}
		}
		
		if (mode == MEMS_MODE){
			display_LED(pitch, count, LED_pins[(led - '1')]);
		}
		
		count++;
	}
}
开发者ID:TheTypoMaster,项目名称:ECSE-426-Microprocessor-System,代码行数:58,代码来源:threads.c


示例7: test_message

int
/*main( int argc, char **argv )
{*/
test_message(){

  char *comeback, one[] = "the quick brown fox", two[]="jumps over the lazy dog";
  pthread_t receive = pthread_self();
  int size;

  /* Don't start if we can't get the message system working. */

  if (messages_init() == MSG_OK) {

    /* Send and receive from destination process 1 (without threads running, we'll receive on thread 1 in torch's pthread implementation. */

    /* Send a single message for starters. */

    if (send_message_to_thread( receive, one, strlen(one)+1) != MSG_OK) {
      printf( "first failed\n" );
    }

    if (receive_message( &receive, &comeback, &size) == MSG_OK) {
      printf ("received message 1--%s--size %d\n", comeback, size );
    } else {
      printf ("first receive failed\n");
    }

    /* Ensure that we can have some capacity in our message system. */

    if (send_message_to_thread( receive, two, strlen(two)+1) != MSG_OK) {
      printf( "second 1 failed\n" );
    }
    if (send_message_to_thread( receive, one, strlen(one)+1) != MSG_OK) {
      printf( "second 2 failed\n" );
    }

    if (receive_message( &receive, &comeback, &size) == MSG_OK) {
      printf ("received message 2--%s--size %d\n", comeback, size );
    } else {
      printf ("second 1 receive failed\n");
    }

    if (receive_message( &receive, &comeback, &size) == MSG_OK) {
      printf ("received message 3--%s--size %d\n", comeback, size );
    } else {
      printf ("second 2 receive failed\n");
    }

    /* Clean up the message system. */

    messages_end();
  }

  return 1;
}
开发者ID:huangyke,项目名称:Multithread-C-Pogram,代码行数:55,代码来源:test_messages.c


示例8: state_check_seeder

static void state_check_seeder()
{
    receive_message();
    if(role == SEEDER) {
        //propagate seederness
        message_out(EMPTY, id, M_SEEDER);
    } else {
        enable_tx = 0;
        message_out(EMPTY, EMPTY, EMPTY);
    }
    _delay_ms(10);
    ++counter;
    if(counter >= CHECK_SEEDER_COUNT) {
        //after CHECK_SEEDER_COUNT rounds, check, whether enough seeders are visible
        RESET_COUNTER;
        if(n_of_seeders() < (MIN_SEEDERS - (role == SEEDER))) {
            //if not, provoke new bottom election
            enable_tx = 1;
            message_out(EMPTY, EMPTY, M_NOT_ENOUGH_SEEDS);
            _delay_ms(100);
            state = ELECT_SEED_BOTTOM;
            if(role != SEEDER)
                role = BOTTOM_SEEDER;
        } else {
            enable_tx = 1;
            state = AWAIT_R_R;
            RESET_COUNTER;
        }
    }
}
开发者ID:kaisert,项目名称:kilobot,代码行数:30,代码来源:BA.c


示例9: test_proc_p2_3

/* Sends message to user process 2 */
void test_proc_p2_3(void) {
    int result_pid = 2;
    msg_buf_t* msg_envelope = 0;
    char* sent_msg = "OS";
    char* received_msg = "SE350";

    msg_envelope = (msg_buf_t*)request_memory_block();

    strncpy(msg_envelope->msg_data, sent_msg, 2);
    send_message(PID_P2, msg_envelope);

    msg_envelope = (msg_buf_t*)receive_message(NULL);

    if (strcmp(msg_envelope->msg_data, received_msg) == 5) {
        printf("G005_test: test 3 OK\r\n");
    } else {
        printf("G005_test: test 3 FAIL\r\n");
        test_results[result_pid] = 0;
    }

    release_memory_block(msg_envelope);
    test_ran[result_pid] = 1;
    set_process_priority(g_test_procs[result_pid].pid, 3);

    while (1) {
        release_processor();
    }
}
开发者ID:nullcat,项目名称:se350-project,代码行数:29,代码来源:test_proc.c


示例10: test_proc_p2_1

/* Delayed Send Test */
void test_proc_p2_1(void) {
    int result_pid = 0;
    msg_buf_t* msg_envelope = NULL;
    char* msg = "Hello";

    msg_envelope = (msg_buf_t*)request_memory_block();

    strncpy(msg_envelope->msg_data, msg, 5);
    delayed_send(PID_P1, msg_envelope, CLOCK_INTERVAL);
    msg_envelope = (msg_buf_t*)receive_message(NULL);

    if (strcmp(msg_envelope->msg_data, msg) == 5) {
        printf("G005_test: test 1 OK\r\n");
    } else {
        printf("G005_test: test 1 FAIL\r\n");
        test_results[result_pid] = 0;
    }

    release_memory_block(msg_envelope);
    test_ran[result_pid] = 1;
    set_process_priority(g_test_procs[result_pid].pid, 3);

    while (1) {
        release_processor();
    }
}
开发者ID:nullcat,项目名称:se350-project,代码行数:27,代码来源:test_proc.c


示例11: process_priority_proc

void process_priority_proc(void) {
    msg_buf* message;
    message = (msg_buf*)request_memory_block();
    message->mtype = KCD_REG;
    copy_string("%C", message->mtext);
    send_message(PID_KCD, message);

    while (1){
        int neg_1 = -1;
        int mtext_len;
        msg_buf* message = (msg_buf*) receive_message(&neg_1);
        if (message == NULL) {
            continue;
        }

        mtext_len = str_len(message->mtext);

        if (message->mtext[1] == 'C' && (mtext_len == 8 || mtext_len == 7)) {
            int p_id;
            int p_priority;

            if (mtext_len == 7) {
                // %C X Y
                p_id = message->mtext[3] - '0';
                p_priority = message->mtext[5] - '0';
            } else {
                // %C XX Y
                p_id = (message->mtext[3] - '0') * 10;
                p_id = message->mtext[4] - '0';
                p_priority = message->mtext[6] - '0';
            }

            if (set_process_priority(p_id, p_priority) == RTX_ERR) {
                msg_buf* err_msg = (msg_buf*)request_memory_block();
							  Node* msg_node = (Node*)request_memory_block();
                err_msg->mtype = CRT_DISPLAY;
                copy_string("Invalid Command for set process priority\n\r", err_msg->mtext);

                //sends error to CRT
                msg_node->sender_id = PID_SET_PRIO;
                msg_node->receiving_id = PID_CRT;
                msg_node->data = err_msg;
                send_message_node(msg_node);
            }

        } else {
            msg_buf* err_msg = (msg_buf*)request_memory_block();
					  Node* msg_node = (Node*)request_memory_block();
            err_msg->mtype = CRT_DISPLAY;
            copy_string("Invalid Format for set process priority\n\r", err_msg->mtext);

            //sends error to CRT
            msg_node->sender_id = PID_SET_PRIO;
            msg_node->receiving_id = PID_CRT;
            msg_node->data = err_msg;
            send_message_node(msg_node);
        }
        release_memory_block(message);
    }
}
开发者ID:chrisjluc,项目名称:SE350,代码行数:60,代码来源:k_system_proc.c


示例12: TNC_IMC_ReceiveMessageLong

/**
 * see section 3.8.6 of TCG TNC IF-IMV Specification 1.3
 */
TNC_Result TNC_IMC_ReceiveMessageLong(TNC_IMCID imc_id,
									  TNC_ConnectionID connection_id,
									  TNC_UInt32 msg_flags,
									  TNC_BufferReference msg,
									  TNC_UInt32 msg_len,
									  TNC_VendorID msg_vid,
									  TNC_MessageSubtype msg_subtype,
									  TNC_UInt32 src_imv_id,
									  TNC_UInt32 dst_imc_id)
{
	imc_state_t *state;
	imc_msg_t *in_msg;
	TNC_Result result;

	if (!imc_os)
	{
		DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name);
		return TNC_RESULT_NOT_INITIALIZED;
	}
	if (!imc_os->get_state(imc_os, connection_id, &state))
	{
		return TNC_RESULT_FATAL;
	}
	in_msg = imc_msg_create_from_long_data(imc_os, state, connection_id,
								src_imv_id, dst_imc_id,msg_vid, msg_subtype,
								chunk_create(msg, msg_len));
	result =receive_message(in_msg);
	in_msg->destroy(in_msg);

	return result;
}
开发者ID:buehler,项目名称:android-hsr-strongswan,代码行数:34,代码来源:imc_os.c


示例13: prcv_mbf

ER
prcv_mbf(ID mbfid, void *msg)
{
	MBFCB	*p_mbfcb;
	uint_t	msgsz;
	bool_t	dspreq;
	ER_UINT	ercd;

	LOG_PRCV_MBF_ENTER(mbfid, msg);
	CHECK_TSKCTX_UNL();
	CHECK_MBFID(mbfid);
	p_mbfcb = get_mbfcb(mbfid);

	t_lock_cpu();
	if ((msgsz = receive_message(p_mbfcb, msg, &dspreq)) > 0U) {
		if (dspreq) {
			dispatch();
		}
		ercd = (ER_UINT) msgsz;
	}
	else {
		ercd = E_TMOUT;
	}
	t_unlock_cpu();

  error_exit:
	LOG_PRCV_MBF_LEAVE(ercd, msg);
	return(ercd);
}
开发者ID:duanlv,项目名称:asp-gr_peach_gcc-mbed,代码行数:29,代码来源:messagebuf.c


示例14: read_char

/* read char */
char read_char() {
    char ch;
    MESSAGE msg;
    if (has_network_socket()) {
        int st;
        msg.msg_type = MSG_GRAPH;
        msg.param.pword[1] = GraphRes;
        msg.param.pword[0] = GRAPH_READCHAR;
        send_to_graph(&msg);
        while (TRUE) {
            st = receive_message(network_socket, &msg);
            if (st == 0) {
                if ((msg.msg_type == MSG_GRAPH) &&
                        (msg.param.pword[0] == GRAPH_READCHAR_RESPONSE)) {
                    ch = msg.param.pchar;
                    break;
                }
            }
        }
        return (ch);
    } else {
        ch = getchar();
        return (ch);
    }

}
开发者ID:lemlang,项目名称:loglan82,代码行数:27,代码来源:cint.c


示例15: priority_switch_command_handler

void priority_switch_command_handler()
{
    // register the command
    MessageEnvelope * kcd_msg = (MessageEnvelope *)request_memory_block();
    kcd_msg->type = TYPE_REGISTER_CMD;
    kcd_msg->msg[0] = '%';
    kcd_msg->msg[1] = 'C';
    send_message(KCD_PID, kcd_msg);

    // loop waiting for messages from the KCD
    while (1) {
        MessageEnvelope * cmd = receive_message(NULL);

        if (cmd->msg[0] != '%' || cmd->msg[1] != 'C' || cmd->msg[2] != ' ') {
            str_copy((BYTE *)"Command was invalid\n\r", (BYTE *)cmd->msg);
            send_message(CRT_PID, cmd);
            continue;
        }

        UINT32 i;

        // find the space in the argument and put a null there so ascii_to_int
        // can parse the two numbers independently
        for (i = 3; cmd->msg[i] != NULL; i ++) {
            if (cmd->msg[i] == ' ') {
                cmd->msg[i] = NULL;
                break;
            }
        }

        SINT32 pid = ascii_to_int(&cmd->msg[3]);
        SINT32 priority = ascii_to_int(&cmd->msg[i + 1]);

        if (pid == -1) {
            str_copy((BYTE *)"PID was invalid\n\r", (BYTE *)cmd->msg);
            send_message(CRT_PID, cmd);
            continue;
        }

        if (priority == -1) {
            str_copy((BYTE *)"Priority was invalid\n\r", (BYTE *)cmd->msg);
            send_message(CRT_PID, cmd);
            continue;
        }

        //rtx_dbug_outs_int("PID: ", pid);
        //rtx_dbug_outs_int("Priority: ", priority);

        int success = set_process_priority(pid, priority);

        if (success != 0) {
            str_copy((BYTE *)"Cannot change that process to that priority\n\r", (BYTE *)cmd->msg);
            send_message(CRT_PID, cmd);
            continue;
        }

        str_copy((BYTE *)"Priority change successful\n\r", (BYTE *)cmd->msg);
        send_message(CRT_PID, cmd);
    }
}
开发者ID:mikesoares,项目名称:ece_354_real_time_operating_system_group_04,代码行数:60,代码来源:priority_switch.c


示例16: state_elect_seeder_bottom

static void state_elect_seeder_bottom()
{
    enable_tx = 1;
    if(role == SEEDER) {
        //top seeders do not participate
        RESET_COUNTER;
        state = CHECK_SEEDER;
        return;
    } else if(role == BOTTOM_SEEDER) {
        //broadcast id, if greater id is encountered, become a usual bot
        message_out(EMPTY, id, M_ELECT_SEED_BOTTOM);
        if(receive_message() == 1) {
            if(message_rx[2] == M_ELECT_SEED_BOTTOM && message_rx[1] > id) {
                role = BOT;
            }
        } else {
            _delay_ms(10);
        }
    }
    if(counter >= ELECT_SEEDER_COUNT_B) {
        //after ELECT_SEEDER_COUNT_B rounds, if role is not BOT, become seeder
        RESET_COUNTER;
        if(role == BOTTOM_SEEDER)
            role = SEEDER;
        state = CHECK_SEEDER;
    }
    _delay_ms(5);
    ++counter;
}
开发者ID:kaisert,项目名称:kilobot,代码行数:29,代码来源:BA.c


示例17: lora_event_handler

// Event handler
static void lora_event_handler(lorawan_event_t event) {
    switch (event) {
        case CONNECTED:
            printf("Connection - Successful\n");
            break;
        case DISCONNECTED:
            ev_queue.break_dispatch();
            printf("Disconnected Successfully\n");
            break;
        case TX_DONE:
            printf("Message Sent to Network Server\n");
            break;
        case TX_TIMEOUT:
        case TX_ERROR:
        case TX_CRYPTO_ERROR:
        case TX_SCHEDULING_ERROR:
            printf("Transmission Error - EventCode = %d\n", event);
            break;
        case RX_DONE:
            printf("Received message from Network Server\n");
            receive_message();
            break;
        case RX_TIMEOUT:
        case RX_ERROR:
            printf("Error in reception - Code = %d\n", event);
            break;
        case JOIN_FAILURE:
            printf("OTAA Failed - Check Keys\n");
            break;
        default:
            MBED_ASSERT("Unknown Event");
    }
}
开发者ID:janjongboom,项目名称:mbed-simulator,代码行数:34,代码来源:main.cpp


示例18: receive_and_forward

char* receive_and_forward(int ant_x, int ant_y, int* src_x, int* src_y, int* size,
                          int threadid, char* send_buf){
  char* msg = receive_message(threadid, src_x, src_y, size);
  //Forward Right
  if(*src_x < ant_x){
    if(ant_x < Nx - 1)
      send_message(*src_x, *src_y, ant_x + 1, ant_y, msg, *size, send_buf);
  }
  //Forward Left
  else if(*src_x > ant_x){
    if(ant_x > 0)
      send_message(*src_x, *src_y, ant_x - 1, ant_y, msg, *size, send_buf);
  }
  //Forward Up
  else if(*src_y < ant_y){
    if(ant_y < Ny - 1)
      send_message(*src_x, *src_y, ant_x, ant_y+1, msg, *size, send_buf);
  }
  //Forward Down
  else if(*src_y > ant_y){
    if(ant_y > 0)
      send_message(*src_x, *src_y, ant_x, ant_y-1, msg, *size, send_buf);
  }
  //Diagonal
  else {
    printf("[receive_and_forward] Diagonal message send not supported.\n");
    exit(-1);
  }
  return msg;
}
开发者ID:simonscott,项目名称:ewallpaper_imaging,代码行数:30,代码来源:data_migration.c


示例19: xt_net_client_system_process_messages

void xt_net_client_system_process_messages(xt_net_client_system_t *client)
{
  xt_core_message_t *message;
  unsigned long message_type;
  xt_net_client_system_handle_message_f handler;
  engine_container_t *engine_container;
  xt_net_engine_id_t engine_id;

  handler = NULL;

  if (ensure_client_is_connected(client)) {
    while ((message = receive_message(client))) {
      message_type = xt_core_message_get_type(message);
      engine_id = xt_core_message_get_engine_id(message);
      engine_container = *(client->engines_array + engine_id);
      if (message_type < engine_container->message_handlers_size) {
        handler = *(engine_container->message_handlers + message_type);
        if (handler) {
          (*handler)(client->custom_client_context, message);
        }
      }
      if (!handler) {
        printf("client has no handler for %s engine's message %lu\n",
            xt_net_engine_get_name(engine_container->engine_id,
                client->get_engine_name),
            message_type);
      }
      xt_core_message_destroy(message);
    }
  } else {
    xt_core_log_trace(client->log, "xnet", "ensure_client_is_connected");
  }
}
开发者ID:xtools,项目名称:xt,代码行数:33,代码来源:system.c


示例20: timer_process

void timer_process(void)
{
    PCB *each_pcb;
    int size, i, on;
    MSG_BUF *each_msg, *received_msg;
    while(1)
    {
        received_msg = receive_message(&size);
				on = atomic_on();
        if(received_msg->mtype == MSG_TIMER_NOTIFICATION)
        {
            for (i = 0; i < gp_pending_message_queue.size; i++)
            {
                each_msg = list_entry(linked_list_get(&gp_pending_message_queue, i), MSG_BUF, m_lnode);
                each_msg->delay--;
                if (each_msg->delay <= 0)
                {
                    each_pcb = get_pcb_by_pid(each_msg->m_recv_pid);
                    linked_list_remove(&gp_pending_message_queue, i);
                    add_to_message_queue(each_pcb, each_msg);
                    i--;
                    if (each_pcb->m_state == BLK && each_pcb->m_blk_reason == BLK_REASON_WAITING_FOR_MSG)
                    {
                        k_unblock_process(each_pcb->m_pid);
                    }
                }
            }
        }
			atomic_off(on);
    }
}
开发者ID:secXsQuared,项目名称:SE350,代码行数:31,代码来源:k_sys_proc.c



注:本文中的receive_message函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ receiver函数代码示例发布时间:2022-05-30
下一篇:
C++ receive_data函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap