ellutionist commented on PR #1418:
URL: 
https://github.com/apache/incubator-kvrocks/pull/1418#issuecomment-1534930672

   @torwig @PragmaTwice The reason why I use `shared_ptr` of 
`SyncMigrateContext` as a field of  `CommandClusterX` is that I have to keep 
the lifetime of `SyncMigrateContext` as long as the command object.
   
   When the `slot_migrator` wake up the `SyncMigrateContext` with a migration 
result status, it has to release the pointer so that no context will "occupy" 
the migrator any more (see 
[here](https://github.com/apache/incubator-kvrocks/pull/1418/files#diff-6a88559b7b94f9543cde3449bda77668eba37d8696153da4f244b250054e809aR1113).
 
   However, at this time point, the `WriteCB` have not been triggered by the 
event loop yet, thus the context cannot be deconstructed yet. Using a shared 
pointer will bind the life cycle of the `SyncMigrateContext` with the 
`CommandClusterX` object, which will solve this issue.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to