Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code style problem #19

Open
microcai opened this issue Jan 6, 2013 · 5 comments
Open

code style problem #19

microcai opened this issue Jan 6, 2013 · 5 comments

Comments

@microcai
Copy link

microcai commented Jan 6, 2013

There is a lot malloc/free . very bad code style

and use busy loop to waiting for messages ( I'm not refer to the pull form TX server, but the pthread that check for the message queue. )

bad code style

lot of void* , bad code style

:(

hope you guys will improve

@xiehuc
Copy link
Collaborator

xiehuc commented Jan 7, 2013

it 's c ; not java ; no gc

i'm also considered this question.

infact i didn't know there is a better way to implement.

if you know. please teach me.

2013/1/6 microcai [email protected]

There is a lot malloc/free . very bad code style

and use busy loop to waiting for messages ( I'm not refer to the pull form
TX server, but the pthread that check for the message queue. )

bad code style

lot of void* , bad code style

:(

hope you guys will improve


Reply to this email directly or view it on GitHubhttps://github.com//issues/19.

@mathslinux
Copy link
Owner

Hi,
Since we developed it with C, so malloc()/free() were unavoidable, but I have wraped them as s_malloc()/s_free(). Maybe for later development, we can implement a memory pool by reworking s_malloc()/s_free() with caller remaining unchanged.

For busy loop designed for receiving messages, I must admit that there are little suck for this design. So, if you have any better suggestion, patches are welcome!

@microcai
Copy link
Author

microcai commented Jan 7, 2013

I have an libwebqq implemented inside qqbot (https://github.com/microcai/qqbot )

Just one thread, no busy loop. two polling connection. every thing is done async.

must of the code is copy&paste from lwqq .

@xiehuc
Copy link
Collaborator

xiehuc commented Jan 7, 2013

good job

2013/1/7 microcai [email protected]

I have an libwebqq implemented inside qqbot (
https://github.com/microcai/qqbot )

Just one thread, no busy loop. two polling connection. every thing is done
async.

must of the code is copy&paste from lwqq .


Reply to this email directly or view it on GitHubhttps://github.com//issues/19#issuecomment-11944677.

@microcai
Copy link
Author

microcai commented Jan 9, 2013

If you develop in C, the trick is to use glib. glib provide g_new/g_free , and for async loop, you have g_main_loop
pruple have pruple loop wrapper arround g_main_loop , you can use neither glib nor pruple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants