Skip to content
This repository was archived by the owner on Feb 24, 2022. It is now read-only.

fix the concurrent problem of handlers in ResponsePromise#188

Open
mashirofang wants to merge 2 commits intojurmous:masterfrom
mashirofang:master
Open

fix the concurrent problem of handlers in ResponsePromise#188
mashirofang wants to merge 2 commits intojurmous:masterfrom
mashirofang:master

Conversation

@mashirofang
Copy link
Copy Markdown

#187
just using a lock to control the concurrent operations

@lburgazzoli
Copy link
Copy Markdown
Collaborator

maybe we just need a CopyOnWriteList instead of the lock/unlock

@mashirofang
Copy link
Copy Markdown
Author

ok , I would conside this better way tomorrow, and commit a new version

@mashirofang
Copy link
Copy Markdown
Author

maybe we just need a CopyOnWriteList instead of the lock/unlock

I think only using CopyOnWriteList may not solve the problem. In this case we won't have any ConcurrentModificationException , but anothor problem might happen that the handler we want to add might be invoked twice both in event-group-thread and user-defined-thread (in a very low probability we addListener just after event-group-thread sets success/exception and before gets iterator of the list to loop ) . So methods such as "addListener" , "handlePromise" and "setException" must be invoked atomicity . Lock/unlock can solve the probleam , but may not good enough , I would spend more time to think it over.

@mashirofang
Copy link
Copy Markdown
Author

mashirofang commented Jun 27, 2019

@lburgazzoli
Hello , I'd thought a lot ,but didn't finger out anyway better than lock/unlock . ReentrantLock is an cas operation , also used in CopyOnWriteList and I use it the same way to control concurrent cases .Anyhow I commit a new version that adjusts some code to reduse the area of the lock .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants