Follow up CL to "Adjust code in response to Burst validation tests"

Bug: 129779280
Bug: 129157135
Test: mma
Change-Id: I36746ba31a6a68ead2a00f6135a5a6db83c32d14
Merged-In: I36746ba31a6a68ead2a00f6135a5a6db83c32d14
(cherry picked from commit 1ee58a58a03d9e9db2e662102023f46a67b01577)
diff --git a/nn/common/ExecutionBurstServer.cpp b/nn/common/ExecutionBurstServer.cpp
index e9dc179..599f57d 100644
--- a/nn/common/ExecutionBurstServer.cpp
+++ b/nn/common/ExecutionBurstServer.cpp
@@ -42,10 +42,7 @@
 
     bool isCacheEntryPresent(int32_t slot) const override {
         const auto it = mMemoryCache.find(slot);
-        if (it == mMemoryCache.end()) {
-            return false;
-        }
-        return it->second.valid();
+        return (it != mMemoryCache.end()) && it->second.valid();
     }
 
     void addCacheEntry(const hidl_memory& memory, int32_t slot) override {
@@ -415,7 +412,11 @@
                 << "ResultChannelSender::sendPacket -- packet size exceeds size available in FMQ";
         const std::vector<FmqResultDatum> errorPacket =
                 serialize(ErrorStatus::GENERAL_FAILURE, {}, kNoTiming);
-        return mFmqResultChannel->writeBlocking(errorPacket.data(), errorPacket.size());
+        if (mBlocking) {
+            return mFmqResultChannel->writeBlocking(errorPacket.data(), errorPacket.size());
+        } else {
+            return mFmqResultChannel->write(errorPacket.data(), errorPacket.size());
+        }
     }
 
     if (mBlocking) {
diff --git a/nn/common/include/ExecutionBurstController.h b/nn/common/include/ExecutionBurstController.h
index 1154b5c..5403b28 100644
--- a/nn/common/include/ExecutionBurstController.h
+++ b/nn/common/include/ExecutionBurstController.h
@@ -192,9 +192,29 @@
      * buffer, they must use the same key.
      */
     class ExecutionBurstCallback : public IBurstCallback {
+        DISALLOW_COPY_AND_ASSIGN(ExecutionBurstCallback);
+
        public:
+        ExecutionBurstCallback() = default;
+
         Return<void> getMemories(const hidl_vec<int32_t>& slots, getMemories_cb cb) override;
 
+        /**
+         * This function performs one of two different actions:
+         * 1) If a key corresponding to a memory resource is unrecognized by the
+         *    ExecutionBurstCallback object, the ExecutionBurstCallback object
+         *    will allocate a slot, bind the memory to the slot, and return the
+         *    slot identifier.
+         * 2) If a key corresponding to a memory resource is recognized by the
+         *    ExecutionBurstCallback object, the ExecutionBurstCallback object
+         *    will return the existing slot identifier.
+         *
+         * @param memories Memory resources used in an inference.
+         * @param keys Unique identifiers where each element corresponds to a
+         *     memory resource element in "memories".
+         * @return Unique slot identifiers where each returned slot element
+         *     corresponds to a memory resource element in "memories".
+         */
         std::vector<int32_t> getSlots(const hidl_vec<hidl_memory>& memories,
                                       const std::vector<intptr_t>& keys);