You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by GitBox <gi...@apache.org> on 2022/06/27 04:34:36 UTC

[GitHub] [incubator-kvrocks] GoGim1 commented on a diff in pull request #682: enhance: use unique_ptr in SlotMigrate and FeedSlaveThread

GoGim1 commented on code in PR #682:
URL: https://github.com/apache/incubator-kvrocks/pull/682#discussion_r906964447


##########
src/slot_migrate.cc:
##########
@@ -104,10 +104,9 @@ Status SlotMigrate::MigrateStart(Server *svr, const std::string &node_id, const
   dst_node_ = node_id;
 
   // Create migration job
-  SlotMigrateJob *job = new SlotMigrateJob(slot, dst_ip, dst_port,
-                                           speed, pipeline_size, seq_gap);
+  slot_job_ = std::unique_ptr<SlotMigrateJob>(new SlotMigrateJob(slot, dst_ip, dst_port,
+                                           speed, pipeline_size, seq_gap));
   std::lock_guard<std::mutex> guard(job_mutex_);
-  slot_job_ = job;

Review Comment:
   sorry, my bad. could i just move Line107 to the scope of the 'lock_guard', or maybe i need to alloc memory for a temp unique_ptr and move the temp unique_ptr's value to slot_job_ in the scope of 'lock_guard'



-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org