mirror of
https://github.com/espressif/openthread.git
synced 2026-07-08 13:20:25 +00:00
[locator] adding OwnerLocator (#2346)
This commit adds a new class `OwnerLocator` which is used by the callback providing types (like `Timer` or `Tasklet`) to remember the owner of the object. This change help simplify the handling of callbacks from such objects. The object itself can be used to get to its owner using `GetOwner<Type>()` method. If support for multiple OpenThread instances is enabled, an `OwnerLocator` object maintains a pointer to the owner. But for the single OpenThread instance scenario, the owner is derived from the single `ot::Instance` object.
This commit is contained in:
committed by
Jonathan Hui
parent
513903061a
commit
5fc97364f3
+3
-3
@@ -3536,13 +3536,13 @@ void Interpreter::SetUserCommands(const otCliCommand *aCommands, uint8_t aLength
|
||||
mUserCommandsLength = aLength;
|
||||
}
|
||||
|
||||
Interpreter &Interpreter::GetOwner(const Context &aContext)
|
||||
Interpreter &Interpreter::GetOwner(OwnerLocator &aOwnerLocator)
|
||||
{
|
||||
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
Interpreter &interpreter = *static_cast<Interpreter *>(aContext.GetContext());
|
||||
Interpreter &interpreter = (aOwnerLocator.GetOwner<Interpreter>());
|
||||
#else
|
||||
Interpreter &interpreter = Uart::sUartServer->GetInterpreter();
|
||||
OT_UNUSED_VARIABLE(aContext);
|
||||
OT_UNUSED_VARIABLE(aOwnerLocator);
|
||||
#endif
|
||||
return interpreter;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user