Calling base class methods

Sven Schwermer sven at svenschwermer.de
Wed Mar 9 18:46:11 UTC 2022


Hi,

I believe, I now understand this. Thank you very much for your explanations!

Best regards,
Sven

On 3/9/22 16:11, Aleksander Morgado wrote:
> Hey,
> 
>> On 3/9/22 15:12, Aleksander Morgado wrote:
>>> You don't invoke the original callback in parent_connect_ready. What
>>> you do in parent_connect_ready is to set as result of your own
>>> connect_3gpp implementation the result you received from the parent.
>>> We don't mix callbacks from different GTasks; actually, you don't even
>>> know if that "res" you received is a GTask or a GSimpleAsyncResult, so
>>> you just treat it as an opaque thing. What you do know is that if you
>>> call an async method passing a ready callback, your ready callback
>>> will be called with the operation is finished, and you should then run
>>> the corresponding async_finish() method to get the result of that
>>> operation. You're chainging async calls here, we don't merge them in
>>> any way.
>>>
>>
>> OK, thanks for the explanation. Do I then need to replicate the logic
>> from the parent class connect_3gpp_ready callback including the logic
>> from connect_succeeded? Or should I perhaps make connect_succeeded
>> publicly available and call it from the derived class connect_3gpp_ready
>> callback?
>>
> 
> You shouldn't need to do that, because the connect_3gpp_ready() method
> in mm-broadband-bearer.c will call MM_BROADBAND_BEARER_GET_CLASS
> (self)->connect_3gpp_finish(), and that would be your own method
> implementation. In other words, if you subclass connect_3gpp() and
> connect_3gpp_finish() and set it as method in the
> MMBroadbandBearerClass, then you just need to wait for those methods
> to be called by the upper level logic. That upper level logic will
> receive your MMBearerConnectResult that your finish() method provides,
> and connect_succeeded() will be called appropriately.
> 
> When you subclass connect_3gpp() and connect_3gpp_finish(), you're not
> touching the connect() method in MMBroadbandBearer, you're just
> re-implementing a step in that logic.
> 


More information about the ModemManager-devel mailing list