Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f9fd8a10
authored
Nov 17, 2014
by
Marcus Winter
Committed by
unknown
Dec 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mtapi_c: extended action plugin api, some cleanup
parent
d6306e93
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
17 deletions
+51
-17
mtapi_c/include/embb/mtapi/c/mtapi_ext.h
+11
-4
mtapi_c/src/embb_mtapi_action_plugin_t.c
+8
-4
mtapi_c/src/embb_mtapi_action_t.c
+6
-1
mtapi_c/src/embb_mtapi_action_t.h
+4
-2
mtapi_c/src/embb_mtapi_task_t.c
+2
-2
mtapi_c/test/embb_mtapi_test_plugin.cc
+20
-4
No files found.
mtapi_c/include/embb/mtapi/c/mtapi_ext.h
View file @
f9fd8a10
...
@@ -36,20 +36,27 @@ extern "C" {
...
@@ -36,20 +36,27 @@ extern "C" {
#endif
#endif
typedef
void
(
*
mtapi_ext_plugin_
action
_start_function_t
)(
typedef
void
(
*
mtapi_ext_plugin_
task
_start_function_t
)(
MTAPI_IN
mtapi_task_hndl_t
task
,
MTAPI_IN
mtapi_task_hndl_t
task
,
MTAPI_OUT
mtapi_status_t
*
status
MTAPI_OUT
mtapi_status_t
*
status
);
);
typedef
void
(
*
mtapi_ext_plugin_
action
_cancel_function_t
)(
typedef
void
(
*
mtapi_ext_plugin_
task
_cancel_function_t
)(
MTAPI_IN
mtapi_task_hndl_t
task
,
MTAPI_IN
mtapi_task_hndl_t
task
,
MTAPI_OUT
mtapi_status_t
*
status
MTAPI_OUT
mtapi_status_t
*
status
);
);
typedef
void
(
*
mtapi_ext_plugin_action_finalize_function_t
)(
MTAPI_IN
mtapi_action_hndl_t
action
,
MTAPI_OUT
mtapi_status_t
*
status
);
mtapi_action_hndl_t
mtapi_ext_plugin_action_create
(
mtapi_action_hndl_t
mtapi_ext_plugin_action_create
(
MTAPI_IN
mtapi_job_id_t
job_id
,
MTAPI_IN
mtapi_job_id_t
job_id
,
MTAPI_IN
mtapi_ext_plugin_action_start_function_t
start_function
,
MTAPI_IN
mtapi_ext_plugin_task_start_function_t
task_start_function
,
MTAPI_IN
mtapi_ext_plugin_action_cancel_function_t
cancel_function
,
MTAPI_IN
mtapi_ext_plugin_task_cancel_function_t
task_cancel_function
,
MTAPI_IN
mtapi_ext_plugin_action_finalize_function_t
action_finalize_function
,
MTAPI_IN
void
*
plugin_data
,
MTAPI_IN
void
*
node_local_data
,
MTAPI_IN
void
*
node_local_data
,
MTAPI_IN
mtapi_size_t
node_local_data_size
,
MTAPI_IN
mtapi_size_t
node_local_data_size
,
MTAPI_IN
mtapi_action_attributes_t
*
attributes
,
MTAPI_IN
mtapi_action_attributes_t
*
attributes
,
...
...
mtapi_c/src/embb_mtapi_action_plugin_t.c
View file @
f9fd8a10
...
@@ -33,8 +33,10 @@
...
@@ -33,8 +33,10 @@
mtapi_action_hndl_t
mtapi_ext_plugin_action_create
(
mtapi_action_hndl_t
mtapi_ext_plugin_action_create
(
MTAPI_IN
mtapi_job_id_t
job_id
,
MTAPI_IN
mtapi_job_id_t
job_id
,
MTAPI_IN
mtapi_ext_plugin_action_start_function_t
start_function
,
MTAPI_IN
mtapi_ext_plugin_task_start_function_t
task_start_function
,
MTAPI_IN
mtapi_ext_plugin_action_cancel_function_t
cancel_function
,
MTAPI_IN
mtapi_ext_plugin_task_cancel_function_t
task_cancel_function
,
MTAPI_IN
mtapi_ext_plugin_action_finalize_function_t
action_finalize_function
,
MTAPI_IN
void
*
plugin_data
,
MTAPI_IN
void
*
node_local_data
,
MTAPI_IN
void
*
node_local_data
,
MTAPI_IN
mtapi_size_t
node_local_data_size
,
MTAPI_IN
mtapi_size_t
node_local_data_size
,
MTAPI_IN
mtapi_action_attributes_t
*
attributes
,
MTAPI_IN
mtapi_action_attributes_t
*
attributes
,
...
@@ -61,8 +63,10 @@ mtapi_action_hndl_t mtapi_ext_plugin_action_create(
...
@@ -61,8 +63,10 @@ mtapi_action_hndl_t mtapi_ext_plugin_action_create(
new_action
->
is_plugin_action
=
MTAPI_TRUE
;
new_action
->
is_plugin_action
=
MTAPI_TRUE
;
embb_atomic_store_int
(
&
new_action
->
num_tasks
,
0
);
embb_atomic_store_int
(
&
new_action
->
num_tasks
,
0
);
new_action
->
plugin_start_function
=
start_function
;
new_action
->
plugin_task_start_function
=
task_start_function
;
new_action
->
plugin_cancel_function
=
cancel_function
;
new_action
->
plugin_task_cancel_function
=
task_cancel_function
;
new_action
->
plugin_action_finalize_function
=
action_finalize_function
;
new_action
->
plugin_data
=
(
void
*
)
plugin_data
;
/* set defaults if no attributes were given */
/* set defaults if no attributes were given */
if
(
MTAPI_NULL
!=
attributes
)
{
if
(
MTAPI_NULL
!=
attributes
)
{
...
...
mtapi_c/src/embb_mtapi_action_t.c
View file @
f9fd8a10
...
@@ -60,6 +60,10 @@ void embb_mtapi_action_initialize(embb_mtapi_action_t* that) {
...
@@ -60,6 +60,10 @@ void embb_mtapi_action_initialize(embb_mtapi_action_t* that) {
}
}
void
embb_mtapi_action_finalize
(
embb_mtapi_action_t
*
that
)
{
void
embb_mtapi_action_finalize
(
embb_mtapi_action_t
*
that
)
{
if
(
that
->
is_plugin_action
)
{
// TODO: check status
that
->
plugin_action_finalize_function
(
that
->
handle
,
NULL
);
}
embb_mtapi_action_initialize
(
that
);
embb_mtapi_action_initialize
(
that
);
}
}
...
@@ -324,7 +328,8 @@ void mtapi_action_delete(
...
@@ -324,7 +328,8 @@ void mtapi_action_delete(
node
,
local_action
->
job_id
);
node
,
local_action
->
job_id
);
embb_mtapi_job_remove_action
(
local_job
,
local_action
);
embb_mtapi_job_remove_action
(
local_job
,
local_action
);
}
}
embb_mtapi_action_finalize
(
local_action
);
/* this is done by pool deallocate:
embb_mtapi_action_finalize(local_action); */
embb_mtapi_action_pool_deallocate
(
node
->
action_pool
,
local_action
);
embb_mtapi_action_pool_deallocate
(
node
->
action_pool
,
local_action
);
}
else
{
}
else
{
local_status
=
MTAPI_ERR_ACTION_INVALID
;
local_status
=
MTAPI_ERR_ACTION_INVALID
;
...
...
mtapi_c/src/embb_mtapi_action_t.h
View file @
f9fd8a10
...
@@ -58,8 +58,10 @@ struct embb_mtapi_action_struct {
...
@@ -58,8 +58,10 @@ struct embb_mtapi_action_struct {
mtapi_boolean_t
enabled
;
mtapi_boolean_t
enabled
;
mtapi_boolean_t
is_plugin_action
;
mtapi_boolean_t
is_plugin_action
;
mtapi_ext_plugin_action_start_function_t
plugin_start_function
;
void
*
plugin_data
;
mtapi_ext_plugin_action_cancel_function_t
plugin_cancel_function
;
mtapi_ext_plugin_task_start_function_t
plugin_task_start_function
;
mtapi_ext_plugin_task_cancel_function_t
plugin_task_cancel_function
;
mtapi_ext_plugin_action_finalize_function_t
plugin_action_finalize_function
;
embb_atomic_int
num_tasks
;
embb_atomic_int
num_tasks
;
};
};
...
...
mtapi_c/src/embb_mtapi_task_t.c
View file @
f9fd8a10
...
@@ -239,7 +239,7 @@ static mtapi_task_hndl_t embb_mtapi_task_start(
...
@@ -239,7 +239,7 @@ static mtapi_task_hndl_t embb_mtapi_task_start(
if
(
local_action
->
is_plugin_action
)
{
if
(
local_action
->
is_plugin_action
)
{
/* schedule plugin task */
/* schedule plugin task */
mtapi_status_t
plugin_status
=
MTAPI_ERR_UNKNOWN
;
mtapi_status_t
plugin_status
=
MTAPI_ERR_UNKNOWN
;
local_action
->
plugin_start_function
(
task_hndl
,
&
plugin_status
);
local_action
->
plugin_
task_
start_function
(
task_hndl
,
&
plugin_status
);
was_scheduled
=
(
MTAPI_SUCCESS
==
plugin_status
)
?
MTAPI_TRUE
:
MTAPI_FALSE
;
was_scheduled
=
(
MTAPI_SUCCESS
==
plugin_status
)
?
MTAPI_TRUE
:
MTAPI_FALSE
;
}
else
{
}
else
{
/* schedule local task */
/* schedule local task */
...
@@ -469,7 +469,7 @@ void mtapi_task_cancel(
...
@@ -469,7 +469,7 @@ void mtapi_task_cancel(
embb_mtapi_action_t
*
local_action
=
embb_mtapi_action_t
*
local_action
=
embb_mtapi_action_pool_get_storage_for_handle
(
node
->
action_pool
,
local_task
->
action
);
embb_mtapi_action_pool_get_storage_for_handle
(
node
->
action_pool
,
local_task
->
action
);
if
(
local_action
->
is_plugin_action
)
{
if
(
local_action
->
is_plugin_action
)
{
local_action
->
plugin_cancel_function
(
task
,
&
local_status
);
local_action
->
plugin_
task_
cancel_function
(
task
,
&
local_status
);
}
}
}
else
{
}
else
{
local_status
=
MTAPI_SUCCESS
;
local_status
=
MTAPI_SUCCESS
;
...
...
mtapi_c/test/embb_mtapi_test_plugin.cc
View file @
f9fd8a10
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include <embb/base/c/thread.h>
#include <embb/base/c/thread.h>
#include <embb/base/c/atomic.h>
#include <embb/base/c/atomic.h>
#include <embb/base/c/internal/unused.h>
#define PLUGIN_JOB_ID 2
#define PLUGIN_JOB_ID 2
...
@@ -43,6 +44,7 @@ mtapi_task_hndl_t plugin_task;
...
@@ -43,6 +44,7 @@ mtapi_task_hndl_t plugin_task;
embb_atomic_int
plugin_task_available
;
embb_atomic_int
plugin_task_available
;
int
plugin_thread_function
(
void
*
args
)
{
int
plugin_thread_function
(
void
*
args
)
{
EMBB_UNUSED
(
args
);
while
(
embb_atomic_load_int
(
&
plugin_running
))
{
while
(
embb_atomic_load_int
(
&
plugin_running
))
{
/* wait for incoming task */
/* wait for incoming task */
while
(
embb_atomic_load_int
(
&
plugin_running
)
&&
!
embb_atomic_load_int
(
&
plugin_task_available
))
while
(
embb_atomic_load_int
(
&
plugin_running
)
&&
!
embb_atomic_load_int
(
&
plugin_task_available
))
...
@@ -70,6 +72,9 @@ void plugin_initialize(
...
@@ -70,6 +72,9 @@ void plugin_initialize(
MTAPI_IN
mtapi_node_t
node_id
,
MTAPI_IN
mtapi_node_t
node_id
,
MTAPI_OUT
mtapi_status_t
*
status
MTAPI_OUT
mtapi_status_t
*
status
)
{
)
{
EMBB_UNUSED
(
domain_id
);
EMBB_UNUSED
(
node_id
);
mtapi_status_t
local_status
=
MTAPI_ERR_UNKNOWN
;
mtapi_status_t
local_status
=
MTAPI_ERR_UNKNOWN
;
int
err
;
int
err
;
...
@@ -102,7 +107,7 @@ void plugin_finalize(
...
@@ -102,7 +107,7 @@ void plugin_finalize(
mtapi_status_set
(
status
,
local_status
);
mtapi_status_set
(
status
,
local_status
);
}
}
void
plugin_
action
_start
(
void
plugin_
task
_start
(
MTAPI_IN
mtapi_task_hndl_t
task
,
MTAPI_IN
mtapi_task_hndl_t
task
,
MTAPI_OUT
mtapi_status_t
*
status
)
{
MTAPI_OUT
mtapi_status_t
*
status
)
{
mtapi_status_t
local_status
=
MTAPI_ERR_UNKNOWN
;
mtapi_status_t
local_status
=
MTAPI_ERR_UNKNOWN
;
...
@@ -125,15 +130,24 @@ void plugin_action_start(
...
@@ -125,15 +130,24 @@ void plugin_action_start(
mtapi_status_set
(
status
,
local_status
);
mtapi_status_set
(
status
,
local_status
);
}
}
void
plugin_
action
_cancel
(
void
plugin_
task
_cancel
(
MTAPI_IN
mtapi_task_hndl_t
task
,
MTAPI_IN
mtapi_task_hndl_t
task
,
MTAPI_OUT
mtapi_status_t
*
status
MTAPI_OUT
mtapi_status_t
*
status
)
{
)
{
EMBB_UNUSED
(
task
);
mtapi_status_t
local_status
=
MTAPI_ERR_UNKNOWN
;
mtapi_status_t
local_status
=
MTAPI_ERR_UNKNOWN
;
mtapi_status_set
(
status
,
local_status
);
mtapi_status_set
(
status
,
local_status
);
}
}
void
plugin_action_finalize
(
MTAPI_IN
mtapi_action_hndl_t
action
,
MTAPI_OUT
mtapi_status_t
*
status
)
{
EMBB_UNUSED
(
action
);
mtapi_status_set
(
status
,
MTAPI_SUCCESS
);
}
PluginTest
::
PluginTest
()
{
PluginTest
::
PluginTest
()
{
CreateUnit
(
"mtapi plugin test"
).
CreateUnit
(
"mtapi plugin test"
).
Add
(
&
PluginTest
::
TestBasic
,
this
);
Add
(
&
PluginTest
::
TestBasic
,
this
);
...
@@ -180,8 +194,10 @@ void PluginTest::TestBasic() {
...
@@ -180,8 +194,10 @@ void PluginTest::TestBasic() {
status
=
MTAPI_ERR_UNKNOWN
;
status
=
MTAPI_ERR_UNKNOWN
;
action
=
mtapi_ext_plugin_action_create
(
action
=
mtapi_ext_plugin_action_create
(
PLUGIN_JOB_ID
,
PLUGIN_JOB_ID
,
plugin_action_start
,
plugin_task_start
,
plugin_action_cancel
,
plugin_task_cancel
,
plugin_action_finalize
,
MTAPI_NULL
,
MTAPI_NULL
,
MTAPI_NULL
,
0
,
0
,
MTAPI_DEFAULT_ACTION_ATTRIBUTES
,
MTAPI_DEFAULT_ACTION_ATTRIBUTES
,
...
...
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