Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sds
remi
Commits
0948ea23
Commit
0948ea23
authored
Aug 10, 2018
by
Matthieu Dorier
Browse files
added method to free user arguments
parent
76c47a56
Changes
4
Hide whitespace changes
Inline
Side-by-side
examples/server.c
View file @
0948ea23
...
...
@@ -71,7 +71,7 @@ int main(int argc, char** argv)
// create migration class
ret
=
remi_provider_register_migration_class
(
remi_prov
,
"my_migration_class"
,
my_migration_callback
,
NULL
);
"my_migration_class"
,
my_migration_callback
,
NULL
,
NULL
);
if
(
ret
!=
REMI_SUCCESS
)
{
fprintf
(
stderr
,
"ERROR: remi_provider_register_migration_class() returned %d
\n
"
,
ret
);
ret
=
-
1
;
...
...
include/remi/remi-server.h
View file @
0948ea23
...
...
@@ -30,6 +30,13 @@ typedef struct remi_provider* remi_provider_t;
typedef
void
(
*
remi_migration_callback_t
)(
remi_fileset_t
,
void
*
);
#define REMI_MIGRATION_CALLBACK_NULL ((remi_migration_callback_t)0)
/**
* @brief Type of callback called on void* user arguments when the
* provider is destroyed.
*/
typedef
void
(
*
remi_uarg_free_t
)(
void
*
);
/**
* @brief Registers a new REMI provider. The provider will be
* automatically destroyed upon finalizing the margo instance.
...
...
@@ -54,6 +61,7 @@ int remi_provider_register(
* @param[in] provider Provider in which to register a migration class.
* @param[in] class_name Migration class name.
* @param[in] callback Callback to call after migration of a fileset of this class.
* @param[in] free_fn Function to call on uargs when the provider is destroyed.
* @param[in] uargs User-argument to pass to the callback.
*
* @return REMI_SUCCESS or error code defined in remi-common.h.
...
...
@@ -62,6 +70,7 @@ int remi_provider_register_migration_class(
remi_provider_t
provider
,
const
char
*
class_name
,
remi_migration_callback_t
callback
,
remi_uarg_free_t
free_fn
,
void
*
uargs
);
#if defined(__cplusplus)
...
...
src/remi-client.cpp
View file @
0948ea23
...
...
@@ -163,7 +163,9 @@ extern "C" int remi_fileset_migrate(
}
// expose the segments for bulk operations
auto
localBulk
=
ph
->
m_client
->
m_engine
->
expose
(
theData
,
tl
::
bulk_mode
::
read_only
);
tl
::
bulk
localBulk
;
if
(
theData
.
size
()
!=
0
)
localBulk
=
ph
->
m_client
->
m_engine
->
expose
(
theData
,
tl
::
bulk_mode
::
read_only
);
// send the RPC
auto
localRoot
=
fileset
->
m_root
;
...
...
src/remi-server.cpp
View file @
0948ea23
...
...
@@ -22,6 +22,7 @@ namespace tl = thallium;
struct
migration_class
{
remi_migration_callback_t
m_callback
;
remi_uarg_free_t
m_free
;
void
*
m_uargs
;
};
...
...
@@ -148,7 +149,13 @@ struct remi_provider : public tl::provider<remi_provider> {
static
void
on_finalize
(
void
*
uargs
)
{
auto
provider
=
static_cast
<
remi_provider_t
>
(
uargs
);
for
(
auto
&
klass
:
provider
->
m_migration_classes
)
{
if
(
klass
.
second
.
m_free
!=
nullptr
)
{
klass
.
second
.
m_free
(
klass
.
second
.
m_uargs
);
}
}
delete
provider
->
m_engine
;
delete
provider
;
}
extern
"C"
int
remi_provider_register
(
...
...
@@ -169,6 +176,7 @@ extern "C" int remi_provider_register_migration_class(
remi_provider_t
provider
,
const
char
*
class_name
,
remi_migration_callback_t
callback
,
remi_uarg_free_t
free_fn
,
void
*
uargs
)
{
if
(
provider
==
REMI_PROVIDER_NULL
||
class_name
==
NULL
)
...
...
@@ -178,5 +186,6 @@ extern "C" int remi_provider_register_migration_class(
auto
&
klass
=
provider
->
m_migration_classes
[
class_name
];
klass
.
m_callback
=
callback
;
klass
.
m_uargs
=
uargs
;
klass
.
m_free
=
free_fn
;
return
REMI_SUCCESS
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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