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

[NEW FEATURE] New threading mode - no threads #9

Closed
silvioprog opened this issue Jan 2, 2019 · 2 comments
Closed

[NEW FEATURE] New threading mode - no threads #9

silvioprog opened this issue Jan 2, 2019 · 2 comments

Comments

@silvioprog
Copy link
Member

silvioprog commented Jan 2, 2019

Since the fourth threading mode of the core allows to disable the internal threads, it would be nice to provide it in the Sagui library too. It would be useful for those applications that already declares a main loop, so the programmers could use it to periodically process the requests and disable the internal library thread/loop.

@silvioprog silvioprog changed the title [FEATURE REQUEST] New threading mode - no threads [POSSIBLE NEW FEATURE] New threading mode - no threads Mar 11, 2019
@silvioprog
Copy link
Member Author

silvioprog commented Mar 20, 2019

Study progress:

  1. it is possible to implement the feature by allowing an external loop which could be managed by select()/epoll().
  2. since select()/epoll() is not cross platform in some compilers/languages, we could provide a function sg_process() that could be called within external loops (application).

Problems, obstacles ...:

  1. it is quite difficult to implement the feature without breaking the current ABI, and it's a little bit early to release another major version.
  2. by design, maybe the feature couldn't be implemented in a single function, then it would grows the final binary anyway.
  3. I've tried to use the MHD's suspend/resume, however I've got an infinity lock in the client socket when tried to combine it with pthread-like threads and select() (asked here plus small spelling correction here).

In short, this feature depends on 5., so, if that is solved, the feature will be implemented.

Another idea was issued here. It would be very useful to reuse the internal library loop too.

@silvioprog silvioprog removed the study label Mar 12, 2020
@silvioprog silvioprog changed the title [POSSIBLE NEW FEATURE] New threading mode - no threads [NEW FEATURE] New threading mode - no threads Mar 12, 2020
@silvioprog
Copy link
Member Author

This feature is unviable to be implemented due to possible blocking calls! An initial implementation was done is this commit, but it locks the entire server when the client calls a route calling a blocking routine. Since MHD already handles it automatically, we are going to let it as it already is.

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