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
a4a37fec
Commit
a4a37fec
authored
Jun 09, 2019
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Imp: add SetTaskPool for session interface
parent
3c7f2913
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
9 deletions
+12
-9
getty.go
getty.go
+1
-0
session.go
session.go
+0
-3
task_pool.go
task_pool.go
+11
-6
No files found.
getty.go
View file @
a4a37fec
...
...
@@ -154,6 +154,7 @@ type Session interface {
SetRQLen
(
int
)
SetWQLen
(
int
)
SetWaitTime
(
time
.
Duration
)
SetTaskPool
(
*
TaskPool
)
GetAttribute
(
interface
{})
interface
{}
SetAttribute
(
interface
{},
interface
{})
...
...
session.go
View file @
a4a37fec
...
...
@@ -647,8 +647,6 @@ func (s *session) handleTCPPackage() error {
break
}
log
.
Errorf
(
"%s, [session.conn.read] = error:%+v"
,
s
.
sessionToken
(),
err
)
// for (Codec)OnErr
// s.errFlag = true
exit
=
true
}
break
...
...
@@ -787,7 +785,6 @@ func (s *session) handleWSPackage() error {
if
err
!=
nil
{
log
.
Warnf
(
"%s, [session.handleWSPackage] = error{%+s}"
,
s
.
sessionToken
(),
err
)
// s.errFlag = true
return
perrors
.
WithStack
(
err
)
}
s
.
UpdateActive
()
...
...
task_pool.go
View file @
a4a37fec
...
...
@@ -29,12 +29,17 @@ type TaskPool struct {
}
// build a task pool
func
newTaskPool
(
opts
TaskPoolOptions
)
*
TaskPool
{
opts
.
validate
()
func
NewTaskPool
(
opts
...
TaskPoolOption
)
*
TaskPool
{
var
tOpts
TaskPoolOptions
for
_
,
opt
:=
range
opts
{
opt
(
&
tOpts
)
}
tOpts
.
validate
()
p
:=
&
TaskPool
{
TaskPoolOptions
:
o
pts
,
qArray
:
make
([]
chan
task
,
o
pts
.
tQNumber
),
TaskPoolOptions
:
tO
pts
,
qArray
:
make
([]
chan
task
,
tO
pts
.
tQNumber
),
done
:
make
(
chan
struct
{}),
}
...
...
@@ -107,7 +112,7 @@ func (p *TaskPool) stop() {
}
// check whether the session has been closed.
func
(
p
*
TaskPool
)
i
sClosed
()
bool
{
func
(
p
*
TaskPool
)
I
sClosed
()
bool
{
select
{
case
<-
p
.
done
:
return
true
...
...
@@ -117,7 +122,7 @@ func (p *TaskPool) isClosed() bool {
}
}
func
(
p
*
TaskPool
)
c
lose
()
{
func
(
p
*
TaskPool
)
C
lose
()
{
p
.
stop
()
p
.
wg
.
Wait
()
for
i
:=
range
p
.
qArray
{
...
...
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