int main(int argc,char **argv) { struct rlimit msglimit ={RLIM_INFINITY ,RLIM_INFINITY }; char *path=argv[1]; struct mq_attr attr; unsigned long msg_size=atol(argv[2]); unsigned long msg_count = atol(argv[3]); int no_of_threads = 1/*atoi(argv[4])*/; int i=0; int more_message=1; MSG_DATA msg; int msge_size=0; MSGQ_attr msg_attr; struct timeval start,end,diff; memset(&msg,0,sizeof(MSG_DATA)); memset(&attr,0,sizeof(struct mq_attr)); memset(&msg_attr,0,sizeof(MSGQ_attr)); assert((msg.data=malloc(msg_size))>0); strncpy(msg_attr.path,path,MAX_PATH_LEN); /* First we need to set up the attribute structure */ attr.mq_maxmsg = msg_count; attr.mq_msgsize = MSGSIZE; attr.mq_flags = 0; memcpy(&(msg_attr.msgq_attr),&attr,sizeof(struct mq_attr)); if(messageq_init(&mq_info,no_of_threads,&msg_attr,WRITE)) { PRINT(LOG_CRITICAL,"message_init failed %lu",msg_count); exit(1); } while(more_message) { printf("Enter the messgae \n"); scanf("%s",msg.data); msg.len=strlen(msg.data); printf("%s %d \n",msg.data,msg.len); getchar(); if(ERROR == send_msg(0,&msg,1)){ PRINT(LOG_CRITICAL,"Unable to send message\n"); } } gettimeofday(&start,NULL); gettimeofday(&end,NULL); diff = time_diff(start,end); printf ("DIFF::%llu.%.6llu",(unsigned long long)diff.tv_sec, (unsigned long long)diff.tv_usec); }
asio_backend_t* asio_backend_init() { asio_backend_t* b = POOL_ALLOC(asio_backend_t); memset(b, 0, sizeof(asio_backend_t)); messageq_init(&b->q); b->wakeup = CreateEvent(NULL, FALSE, FALSE, NULL); b->stop = false; if(b->wakeup == NULL) { POOL_FREE(asio_backend_t, b); return NULL; } return b; }
asio_backend_t* asio_backend_init() { asio_backend_t* b = POOL_ALLOC(asio_backend_t); memset(b, 0, sizeof(asio_backend_t)); messageq_init(&b->q); b->epfd = epoll_create1(EPOLL_CLOEXEC); b->wakeup = eventfd(0, EFD_NONBLOCK); if(b->epfd == 0 || b->wakeup == 0) { POOL_FREE(asio_backend_t, b); return NULL; } struct epoll_event ep; ep.data.ptr = b; ep.events = EPOLLIN | EPOLLRDHUP | EPOLLET; epoll_ctl(b->epfd, EPOLL_CTL_ADD, b->wakeup, &ep); return b; }