Skip to content

Commit 088c6c6

Browse files
aarongreigkbenzie
authored andcommitted
Make callbacks singleton into a helper function
1 parent c90c6d0 commit 088c6c6

File tree

10 files changed

+690
-612
lines changed

10 files changed

+690
-612
lines changed

include/ur_api.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,8 @@ urLoaderConfigSetCodeLocationCallback(
750750
/// - The mock adapter will default to returning ::UR_RESULT_SUCCESS for all
751751
/// entry points. It will also create and correctly reference count dummy
752752
/// handles where appropriate. Its behaviour can be modified by linking
753-
/// the ::ur_mock_headers library and using the mock::callbacks object.
753+
/// the mock library and using the object accessed via
754+
/// mock::getCallbacks().
754755
///
755756
/// @returns
756757
/// - ::UR_RESULT_SUCCESS

scripts/core/INTRO.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,12 @@ handles that track a reference count, and ``Retain``/``Release`` entry points wi
269269
function as expected when used with these handles.
270270

271271
The behavior of the mock adapter can be customized by linking the
272-
``unified-runtime::mock`` library and making use of the ``mock::callbacks``
273-
object. Callbacks can be passed into this object to run either before or after a
274-
given entry point, or they can be set to entirely replace the default behavior.
275-
Only one callback of each type (before, replace, after) can be set per entry
276-
point, with subsequent callbacks set in the same "slot" overwriting any set
277-
previously.
272+
``unified-runtime::mock`` library and making use of the object accessed via the
273+
``mock::getCallbacks()`` helper. Callbacks can be passed into this object to
274+
run either before or after a given entry point, or they can be set to entirely
275+
replace the default behavior. Only one callback of each type (before, replace,
276+
after) can be set per entry point, with subsequent callbacks set in the same
277+
"slot" overwriting any set previously.
278278

279279
The callback signature defined by ``ur_mock_callback_t`` takes a single
280280
``void *`` parameter. When calling a user callback the adapter will pack the

scripts/core/loader.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ params:
190190
type: function
191191
desc: "The only adapter reported with mock enabled will be the mock adapter."
192192
details:
193-
- "The mock adapter will default to returning $X_RESULT_SUCCESS for all entry points. It will also create and correctly reference count dummy handles where appropriate. Its behaviour can be modified by linking the $x_mock_headers library and using the mock::callbacks object."
193+
- "The mock adapter will default to returning $X_RESULT_SUCCESS for all entry points. It will also create and correctly reference count dummy handles where appropriate. Its behaviour can be modified by linking the mock library and using the object accessed via mock::getCallbacks()."
194194
class: $xLoaderConfig
195195
loader_only: True
196196
name: "SetMockingEnabled"

scripts/templates/mockddi.cpp.mako

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace driver
4444
${th.make_pfncb_param_type(n, tags, obj)} params = { &${",&".join(th.make_param_lines(n, tags, obj, format=["name"]))} };
4545

4646
auto beforeCallback = reinterpret_cast<ur_mock_callback_t>(
47-
mock::callbacks.get_before_callback("${fname}"));
47+
mock::getCallbacks().get_before_callback("${fname}"));
4848
if(beforeCallback) {
4949
result = beforeCallback( &params );
5050
if(result != UR_RESULT_SUCCESS) {
@@ -53,7 +53,7 @@ namespace driver
5353
}
5454

5555
auto replaceCallback = reinterpret_cast<ur_mock_callback_t>(
56-
mock::callbacks.get_replace_callback("${fname}"));
56+
mock::getCallbacks().get_replace_callback("${fname}"));
5757
if(replaceCallback) {
5858
result = replaceCallback( &params );
5959
}
@@ -130,7 +130,7 @@ namespace driver
130130
}
131131

132132
auto afterCallback = reinterpret_cast<ur_mock_callback_t>(
133-
mock::callbacks.get_after_callback("${fname}"));
133+
mock::getCallbacks().get_after_callback("${fname}"));
134134
if(afterCallback) {
135135
return afterCallback( &params );
136136
}

0 commit comments

Comments
 (0)