Hi Nick, thanks for replying :-) >I shouldn't have implied that stack-allocating lots of struct event is >a good idea. The typical usage pattern for event_assign() is >sticking the struct event inside another structure which you then in >turn heap-allocate, like the example does it.
Yes, is what I thought too... Is was basing my confusion on the example here (http://wangafu.net/~nickm/libevent-book/01_intro.html - on alloc_fd_state function) >Have you heard the old Knuth saying, "Premature optimization is the >root of all evil in programming"? Typically, it's better to write >your code to be simple, maintainable, and correct, and not spend time >optimizing it until you know, through actual measurement, where the >performance issues lie. Everyday :-) That' why I'm following the doc's examples step-by-step as you said ;) >I shouldn't have implied that stack-allocating lots of struct event is >a good idea. The typical usage pattern for event_assign() is >sticking the struct event inside another structure which you then in >turn heap-allocate, like the example does it. >Even then, it's a fairly error prone thing that, like the document >says, you should not do until you *know* it is actually an issue for >your application. There's where my confusion lies. In the fact that even in that case could led to error prone as you said in the documentation. But as I see right now you have uploaded new changes on the documentation and everything is as clear as water! As the new changes on the doc says: >"These are very small costs, and do not matter for most applications. You should just stick to using event_new() unless you know that you’re incurring a significant performance penalty for heap-allocating your events. Using this function can cause >hard-do-diagnose errors with future versions of Libevent if they use a larger event structure than the one you’re building with." Thank you so much for you help and support! Best regards, Raine
_______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users