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

Patch: Add Thread Enter/Exit Events #345

Open
GoogleCodeExporter opened this issue Mar 16, 2015 · 2 comments
Open

Patch: Add Thread Enter/Exit Events #345

GoogleCodeExporter opened this issue Mar 16, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

To make it easier to do database connection pooling in my app, I've created 
this patch to expand the callback functions so that they provide calls when 
each worker thread starts and stops. This should not cause any added overhead 
since the number of worker threads is static.

The comments in the mongoose.h should be self-explanatory.

Events added: MG_ENTER_THREAD, MG_EXIT_THREAD (These events receive unusual 2nd 
and 3rd parameters. Since there is no socket connection when they are called, 
the 2nd parameter is replaced by the void *user_data originally passed to 
mg_start().)

Structures modified: mg_request_info -> added void* thread_ctx

Functions modified: worker_thread()

Tested only on Windows, with Visual Studio 6.

Original issue reported on code.google.com by [email protected] on 17 Apr 2012 at 5:34

Attachments:

@GoogleCodeExporter
Copy link
Author

This could actually also be used to set the priorities of the worker threads to 
a value that is appropriate for the individual system - together with a similar 
event for the master thread.



Original comment by [email protected] on 24 Apr 2012 at 3:59

@GoogleCodeExporter
Copy link
Author

I considered adding a master thread hook when I was making the patch but I 
don't have a need for it and I try to follow the "You Won't Need It" principle 
whenever possible. Now if there is a need, I could add it. Probably would use 
MG_ENTER_MASTER and MG_EXIT_MASTER as the event IDs to make things simple.

Original comment by [email protected] on 24 Apr 2012 at 4:15

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

No branches or pull requests

1 participant