1 2 /** 3 * Tencent is pleased to support the open source community by making MSEC available. 4 * 5 * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 6 * 7 * Licensed under the GNU General Public License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. You may 9 * obtain a copy of the License at 10 * 11 * https://opensource.org/licenses/GPL-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software distributed under the 14 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 * either express or implied. See the License for the specific language governing permissions 16 * and limitations under the License. 17 */ 18 19 20 /** 21 * @file mt_concurrent.h 22 * @info ��չ״̬�̵߳Ĵ���ģ�� 23 * @time 20130515 24 **/ 25 26 #ifndef __MT_CONCURRENT_H__ 27 #define __MT_CONCURRENT_H__ 28 29 #include <netinet/in.h> 30 #include <vector> 31 32 namespace NS_MICRO_THREAD { 33 34 using std::vector; 35 36 class IMtAction; 37 typedef vector<IMtAction*> IMtActList; 38 39 /******************************************************************************/ 40 /* �߳��û��ӿڶ���: �߳�Action��·����ģ�ͽӿڶ��� */ 41 /******************************************************************************/ 42 43 /** 44 * @brief ��·IO�������մ���ӿ�, ��װACTON�ӿ�ģ��, �ڲ�����msg 45 * @param req_list -action list ʵ�ַ�װ�����ӿ� 46 * @param timeout -��ʱʱ��, ��λms 47 * @return 0 �ɹ�, -1 ��socketʧ��, -2 ��������ʧ��, -100 ����Ӧ��ʧ��, �ɴ�ӡerrno 48 */ 49 int mt_msg_sendrcv(IMtActList& req_list, int timeout); 50 51 /******************************************************************************/ 52 /* �ڲ�ʵ�ֶ��岿�� */ 53 /******************************************************************************/ 54 55 /** 56 * @brief ��·IO�Ĵ����Ż�, �첽���ȵȴ����� 57 * @param req_list - �����б� 58 * @param how - EPOLLIN EPOLLOUT 59 * @param timeout - ��ʱʱ�� ���뵥λ 60 * @return 0 �ɹ�, <0ʧ�� -3 ����ʱ 61 */ 62 int mt_multi_netfd_poll(IMtActList& req_list, int how, int timeout); 63 64 /** 65 * @brief Ϊÿ��ITEM���������ĵ�socket 66 * @param req_list - �����б� 67 * @return 0 �ɹ�, <0ʧ�� 68 */ 69 int mt_multi_newsock(IMtActList& req_list); 70 71 /** 72 * @brief ��·IO�Ĵ���, ������ 73 * @param req_list - �����б� 74 * @param timeout - ��ʱʱ�� ���뵥λ 75 * @return 0 �ɹ�, <0ʧ�� 76 */ 77 int mt_multi_open(IMtActList& req_list, int timeout); 78 79 /** 80 * @brief ��·IO�Ĵ���, �������� 81 * @param req_list - �����б� 82 * @param timeout - ��ʱʱ�� ���뵥λ 83 * @return 0 �ɹ�, <0ʧ�� 84 */ 85 int mt_multi_sendto(IMtActList& req_list, int timeout); 86 87 /** 88 * @brief ��·IO�������մ��� 89 */ 90 int mt_multi_recvfrom(IMtActList& req_list, int timeout); 91 92 /** 93 * @brief ��·IO�������մ��� 94 */ 95 int mt_multi_sendrcv_ex(IMtActList& req_list, int timeout); 96 97 } 98 99 100 101 #endif 102 103 104