mirror of
https://github.com/espressif/openthread.git
synced 2026-08-01 16:47:47 +00:00
[instance-locator] use instance reference instead of pointer (#2007)
This commit changes the `InstanceLocator` class to keep track of a reference to `otInstance` (instead of a pointer) to make it behave similar to other `ObjectLocator` classes. The method `GetInstance()` in all locator objects is updated to provide a reference (instead of a pointer) to `otInstance`. The logging macros are updated such that a reference to `otInstance` is passed as the first argument (with the exception of `otLog<Level>Plat()` macros which are used by platform code in C domain). The documentation for log macros are also updated.
This commit is contained in:
committed by
Jonathan Hui
parent
ea73c92151
commit
fc72e4e719
+14
-14
@@ -85,7 +85,7 @@ void InitCounters(void)
|
||||
class TestTimer: public ot::TimerMilli
|
||||
{
|
||||
public:
|
||||
TestTimer(otInstance *aInstance):
|
||||
TestTimer(otInstance &aInstance):
|
||||
ot::TimerMilli(aInstance, TestTimer::HandleTimerFired, NULL),
|
||||
mFiredCounter(0)
|
||||
{ }
|
||||
@@ -115,7 +115,7 @@ int TestOneTimer(void)
|
||||
const uint32_t kTimeT0 = 1000;
|
||||
const uint32_t kTimerInterval = 10;
|
||||
otInstance *instance = testInitInstance();
|
||||
TestTimer timer(instance);
|
||||
TestTimer timer(*instance);
|
||||
|
||||
// Test one Timer basic operation.
|
||||
|
||||
@@ -241,8 +241,8 @@ int TestTwoTimers(void)
|
||||
const uint32_t kTimeT0 = 1000;
|
||||
const uint32_t kTimerInterval = 10;
|
||||
otInstance *instance = testInitInstance();
|
||||
TestTimer timer1(instance);
|
||||
TestTimer timer2(instance);
|
||||
TestTimer timer1(*instance);
|
||||
TestTimer timer2(*instance);
|
||||
|
||||
InitTestTimer();
|
||||
printf("TestTwoTimers() ");
|
||||
@@ -526,16 +526,16 @@ static void TenTimers(uint32_t aTimeShift)
|
||||
|
||||
otInstance *instance = testInitInstance();
|
||||
|
||||
TestTimer timer0(instance);
|
||||
TestTimer timer1(instance);
|
||||
TestTimer timer2(instance);
|
||||
TestTimer timer3(instance);
|
||||
TestTimer timer4(instance);
|
||||
TestTimer timer5(instance);
|
||||
TestTimer timer6(instance);
|
||||
TestTimer timer7(instance);
|
||||
TestTimer timer8(instance);
|
||||
TestTimer timer9(instance);
|
||||
TestTimer timer0(*instance);
|
||||
TestTimer timer1(*instance);
|
||||
TestTimer timer2(*instance);
|
||||
TestTimer timer3(*instance);
|
||||
TestTimer timer4(*instance);
|
||||
TestTimer timer5(*instance);
|
||||
TestTimer timer6(*instance);
|
||||
TestTimer timer7(*instance);
|
||||
TestTimer timer8(*instance);
|
||||
TestTimer timer9(*instance);
|
||||
TestTimer *timers[kNumTimers] =
|
||||
{
|
||||
&timer0,
|
||||
|
||||
Reference in New Issue
Block a user