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

Make libyaep reentrant #12

Open
TheCount opened this issue Sep 30, 2018 · 3 comments
Open

Make libyaep reentrant #12

TheCount opened this issue Sep 30, 2018 · 3 comments

Comments

@TheCount
Copy link

YAEP currently manipulates a lot of static variables during its operation. This makes it impossible to use multiple parsers asynchronously.

One simple preliminary fix would be to declare all these variables thread_local. While this does not make libyaep reentrant, it would at least become possible to use multiple parsers concurrently, as long as each parser has a thread of its own and stays on that thread. This preliminary fix would, strictly speaking, break the API, though, because it would no longer be possible to use the same parser from different threads.

The better fix would be to make libyaep fully reentrant by eliminating all static variables. Unless extra parameters are required for this for exposed functions, this could be implemented without breaking the API. Parsers could then be used asynchronously and, as long the caller adheres to a few simple rules, would also be thread-safe.

@vnmakarov
Copy link
Owner

Thank you for raising the issue.

Basically YAEP was written about 20 years ago and was a part of COCOM tool set. Concurrency was not a mainstream that time.

I guess it is possible to make YAEP thread-safe by adding global vars to grammar object. If it is not true, new thread-safe functions could be a solution to save API compatibility. On the other hand, I don't think YAEP is widely used to be worry about breaking API.

Unfortunately, I am too busy to address this issue (these days I have many other projects to work on).

@TheCount
Copy link
Author

Understood. I'll give it a shot, but my time is also limited, so I can't make any promises.

In any case, thanks for writing YAEP.

@TheCount
Copy link
Author

TheCount commented Oct 3, 2018

Just a heads-up: the allocator used by YAEP is not thread-safe/reentrant by itself. So I'll try to fix the allocator first, then YAEP.

TheCount added a commit to TheCount/yaep that referenced this issue Nov 11, 2018
TheCount added a commit to TheCount/yaep that referenced this issue Nov 11, 2018
TheCount added a commit to TheCount/yaep that referenced this issue Nov 11, 2018
TheCount added a commit to TheCount/yaep that referenced this issue Nov 11, 2018
As a test, eliminate the static global variable anode_cost.

Required for vnmakarov#12.
TheCount added a commit to TheCount/yaep that referenced this issue Nov 11, 2018
Eliminate all global variables not needed in sread_terminal() or
sread_rule().

Required for vnmakarov#12.
TheCount added a commit to TheCount/yaep that referenced this issue Nov 11, 2018
Eliminate remaining global variables used by sread_terminal() and
sread_rule() by passing parser data via reentrancy hack.

Required for vnmakarov#12.
TheCount added a commit to TheCount/yaep that referenced this issue Nov 21, 2018
TheCount added a commit to TheCount/yaep that referenced this issue Nov 21, 2018
TheCount added a commit to TheCount/yaep that referenced this issue Nov 21, 2018
TheCount added a commit to TheCount/yaep that referenced this issue Nov 22, 2018
TheCount added a commit to TheCount/yaep that referenced this issue Nov 22, 2018
TheCount added a commit to TheCount/yaep that referenced this issue Nov 22, 2018
TheCount added a commit to TheCount/yaep that referenced this issue Nov 25, 2018
TheCount added a commit to TheCount/yaep that referenced this issue Nov 25, 2018
TheCount added a commit to TheCount/yaep that referenced this issue Nov 28, 2018
TheCount added a commit to TheCount/yaep that referenced this issue Nov 28, 2018
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
As a test, eliminate the static global variable anode_cost.

Required for vnmakarov#12.
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
Eliminate all global variables not needed in sread_terminal() or
sread_rule().

Required for vnmakarov#12.
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
Eliminate remaining global variables used by sread_terminal() and
sread_rule() by passing parser data via reentrancy hack.

Required for vnmakarov#12.
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
TheCount added a commit to TheCount/yaep that referenced this issue Mar 1, 2022
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

2 participants