Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jlib
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
captainwong
jlib
Commits
9c549958
Commit
9c549958
authored
4 years ago
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
find_clients
parent
494c3f92
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
1 deletion
+18
-1
simple_libevent_clients.cpp
jlib/net/simple_libevent_clients.cpp
+14
-0
simple_libevent_clients.h
jlib/net/simple_libevent_clients.h
+1
-1
test.sln
test/test.sln
+3
-0
No files found.
jlib/net/simple_libevent_clients.cpp
View file @
9c549958
...
@@ -480,6 +480,20 @@ void simple_libevent_clients::exit()
...
@@ -480,6 +480,20 @@ void simple_libevent_clients::exit()
impl
=
nullptr
;
impl
=
nullptr
;
}
}
simple_libevent_clients
::
BaseClient
*
simple_libevent_clients
::
find_client
(
int
fd
)
{
std
::
lock_guard
<
std
::
mutex
>
lg
(
mutex_
);
if
(
!
impl
)
{
return
nullptr
;
}
for
(
int
i
=
0
;
i
<
threadNum_
;
i
++
)
{
std
::
lock_guard
<
std
::
mutex
>
lg2
(
impl
->
contexts
[
i
]
->
mutex
);
auto
iter
=
impl
->
contexts
[
i
]
->
clients
.
find
(
fd
);
if
(
iter
!=
impl
->
contexts
[
i
]
->
clients
.
end
())
{
return
iter
->
second
;
}
}
return
nullptr
;
}
void
simple_libevent_clients
::
BaseClient
::
set_timer
(
OnTimerCallback
cb
,
void
*
user_data
,
int
seconds
)
void
simple_libevent_clients
::
BaseClient
::
set_timer
(
OnTimerCallback
cb
,
void
*
user_data
,
int
seconds
)
{
{
...
...
This diff is collapsed.
Click to expand it.
jlib/net/simple_libevent_clients.h
View file @
9c549958
...
@@ -87,7 +87,7 @@ public:
...
@@ -87,7 +87,7 @@ public:
bool
connect
(
const
std
::
string
&
ip
,
uint16_t
port
,
std
::
string
&
msg
);
bool
connect
(
const
std
::
string
&
ip
,
uint16_t
port
,
std
::
string
&
msg
);
void
exit
();
void
exit
();
BaseClient
*
find_client
(
int
fd
);
protected
:
protected
:
...
...
This diff is collapsed.
Click to expand it.
test/test.sln
View file @
9c549958
...
@@ -90,6 +90,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net", "net", "{FEAECF59-4F3
...
@@ -90,6 +90,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net", "net", "{FEAECF59-4F3
..\jlib\net\resolve_fastest_ip.h = ..\jlib\net\resolve_fastest_ip.h
..\jlib\net\resolve_fastest_ip.h = ..\jlib\net\resolve_fastest_ip.h
..\jlib\net\simple_libevent_client.cpp = ..\jlib\net\simple_libevent_client.cpp
..\jlib\net\simple_libevent_client.cpp = ..\jlib\net\simple_libevent_client.cpp
..\jlib\net\simple_libevent_client.h = ..\jlib\net\simple_libevent_client.h
..\jlib\net\simple_libevent_client.h = ..\jlib\net\simple_libevent_client.h
..\jlib\net\simple_libevent_clients.cpp = ..\jlib\net\simple_libevent_clients.cpp
..\jlib\net\simple_libevent_clients.h = ..\jlib\net\simple_libevent_clients.h
..\jlib\net\simple_libevent_micros.h = ..\jlib\net\simple_libevent_micros.h
..\jlib\net\simple_libevent_server.cpp = ..\jlib\net\simple_libevent_server.cpp
..\jlib\net\simple_libevent_server.cpp = ..\jlib\net\simple_libevent_server.cpp
..\jlib\net\simple_libevent_server.h = ..\jlib\net\simple_libevent_server.h
..\jlib\net\simple_libevent_server.h = ..\jlib\net\simple_libevent_server.h
EndProjectSection
EndProjectSection
...
...
This diff is collapsed.
Click to expand it.
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