Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
k-sdk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈伟灿
k-sdk
Commits
56cc6d14
Commit
56cc6d14
authored
Jul 27, 2020
by
黄振令
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Author: huang.zhenling
Root Cause: 优化api How2Fix:
parent
84f4eea9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
15 deletions
+19
-15
common/api/com_api.c
common/api/com_api.c
+18
-14
common/api/com_api.h
common/api/com_api.h
+1
-1
No files found.
common/api/com_api.c
View file @
56cc6d14
...
...
@@ -14,6 +14,7 @@ typedef struct {
}
Bloop_ctrl_t
;
Bloop_ctrl_t
Bloop_ctrl
;
static
struct
ev_io
g_watcher
;
struct
ev_loop
*
gloop
;
ipc_cb
*
g_cb
=
NULL
;
...
...
@@ -103,28 +104,28 @@ int __nanomsg_init(Bloop_ctrl_t *Bloop_ctrl, ipc_type type)
*
==================================*/
void
loop_thread
(
void
*
arg
){
struct
ev_loop
*
loop
=
__loop_init
(
&
Bloop_ctrl
);
if
(
NULL
==
loop
)
{
printf
(
"loop init failed
\r\n
"
);
g
loop
=
__loop_init
(
&
Bloop_ctrl
);
if
(
NULL
==
g
loop
)
{
printf
(
"
g
loop init failed
\r\n
"
);
return
;
}
ev_set_userdata
(
loop
,
&
Bloop_ctrl
);
ev_run
(
loop
,
0
);
ev_set_userdata
(
g
loop
,
&
Bloop_ctrl
);
ev_run
(
g
loop
,
0
);
}
void
kk_ipc_init
(
ipc_type
type
,
ipc_cb
cb
)
int
kk_ipc_init
(
ipc_type
type
,
ipc_cb
cb
)
{
pthread_t
pb
;
if
(
g_cb
=
=
NULL
){
if
(
g_cb
!
=
NULL
){
printf
(
"ipc has been inited!
\r\n
"
);
return
;
return
-
1
;
}
if
(
__nanomsg_init
(
&
Bloop_ctrl
,
type
)
<
0
)
{
printf
(
"nanomsg init failed
\r\n
"
);
return
;
return
-
1
;
}
if
(
0
!=
pthread_create
(
&
pb
,
NULL
,
loop_thread
,
NULL
))
{
...
...
@@ -132,20 +133,21 @@ void kk_ipc_init(ipc_type type, ipc_cb cb)
return
-
1
;
}
g_cb
=
cb
;
return
;
return
0
;
}
int
kk_ipc_dinit
()
{
#if 0
if
(
Bloop_ctrl
.
ba
.
n
>
-
1
){
nn_shutdown
(
Bloop_ctrl
.
ba
.
n
,
0
);
}
ev_io_stop(g_watcher);
ev_break(EV_A_ EVBREAK_ALL);
ev_io_stop
(
gloop
,
&
g_watcher
);
ev_break
(
gloop
,
EVBREAK_ALL
);
g_cb
=
NULL
;
#endif
return
0
;
}
...
...
@@ -160,4 +162,6 @@ int kk_ipc_send(void* data)
//printf("kk_ipc_send: RECEIVED \"%s\"\n", data);
}
return
0
;
}
common/api/com_api.h
View file @
56cc6d14
...
...
@@ -27,7 +27,7 @@ typedef enum {
}
ipc_type
;
typedef
void
ipc_cb
(
void
*
data
);
void
kk_ipc_init
(
ipc_type
type
,
ipc_cb
cb
);
int
kk_ipc_init
(
ipc_type
type
,
ipc_cb
cb
);
int
kk_ipc_dinit
();
int
kk_ipc_send
(
void
*
data
);
...
...
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