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

One Event Que and One Event Handling goroutine for every Proxy #6

Open
ChengAnXu2014 opened this issue Feb 16, 2023 · 0 comments
Open

Comments

@ChengAnXu2014
Copy link

ChengAnXu2014 commented Feb 16, 2023

Since GO's goroutine is lightweight thread and GO's Channel is perfect Queue, is very easy to give every Proxy a goroutine and Event Que.
In every goroutine use a loop to get Event from Event Que and handle it.
The problem is how to "flush" a Proxy Event Que?
My anser is to use a Mark Event.
A Mark Event markEvt is a special Event which hold a Channel markEvt.SyncCh=make(chan byte, 1).
When I wanna "flush" Proxy pA's Event Que, I use Display.Sync to get a Callback, in Callback's DoneHandler I put a Mark Event markEvt in pA's Event Que ch:=make(chan byte,1);pA.EvtQue<-&Event{SyncCh: ch}, and use <-ch to block my goroutine.
When pA's Event Handle Loop get a Event evt that evt.SyncCh!=nil, it will use evt.SyncCh<-0 to unblock my goroutine.

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

1 participant