Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
getty
Commits
1c98c491
Commit
1c98c491
authored
Oct 22, 2016
by
alexstocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add remark
parent
8f2ddfa7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
session.go
session.go
+2
-0
version.go
version.go
+25
-0
No files found.
session.go
View file @
1c98c491
...
...
@@ -445,6 +445,8 @@ func (this *Session) handleLoop() {
// ticker = time.NewTicker(this.period) // use wheel instead, 2016/09/26
LOOP
:
for
{
// A select blocks until one of its cases can run, then it executes that case.
// It choose one at random if multiple are ready. Otherwise it choose default branch if none is ready.
select
{
case
<-
this
.
done
:
// 这个分支确保(Session)handleLoop gr在(Session)handlePackage gr之后退出
...
...
version.go
View file @
1c98c491
...
...
@@ -16,3 +16,28 @@ const (
GETTY_MINOR
=
4
GETTY_BUILD
=
5
)
/*
几个可能的优化点:
1 session.go:Session中的rQ & wQ 均是channel实现,其本质是bounded queue,所以可能导致读写阻塞,如果想让write更快一点,可以使用list作为wQ的二级队列,以存放优先级比较高的且不能丢弃(在wQ full的情况下)的pkg;
2 codec.go:(EventListener)OnMessage其实可以一次处理多个session.go:Session{rQ}的多个包,如:
const MAX = 32
for {
select {
case inPkg = <-this.rQ:
if flag {
var pkgArray []interface{}
pkgArray = append(pkgArray, inPkg)
Read:
for i := 0; i < MAX; i++ {
case inPkg = <-this.rQ:
pkgArray = append(pkgArray, inPkg)
default:
break Read
}
this.listener.OnMessages(this, pkgArray)
this.incReadPkgCount(len(pkgArray))
} else {
log.Info("[session.handleLoop] drop readin package{%#v}", inPkg)
}
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment