Revision b45fbc1175fb83080405af6732881db272e462e0 authored by Prashant D on 28 November 2017, 21:15:20 UTC, committed by Facebook Github Bot on 28 November 2017, 21:27:08 UTC
Summary:
```
utilities/persistent_cache/block_cache_tier_file.cc
64struct CacheRecordHeader {
   	2. uninit_member: Non-static class member magic_ is not initialized in this constructor nor in any functions that it calls.
   	4. uninit_member: Non-static class member crc_ is not initialized in this constructor nor in any functions that it calls.
   	6. uninit_member: Non-static class member key_size_ is not initialized in this constructor nor in any functions that it calls.

CID 1396161 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
8. uninit_member: Non-static class member val_size_ is not initialized in this constructor nor in any functions that it calls.
 65  CacheRecordHeader() {}
 66  CacheRecordHeader(const uint32_t magic, const uint32_t key_size,
 67                    const uint32_t val_size)
 68      : magic_(magic), crc_(0), key_size_(key_size), val_size_(val_size) {}
 69
   	1. member_decl: Class member declaration for magic_.
 70  uint32_t magic_;
   	3. member_decl: Class member declaration for crc_.
 71  uint32_t crc_;
   	5. member_decl: Class member declaration for key_size_.
 72  uint32_t key_size_;
   	7. member_decl: Class member declaration for val_size_.
 73  uint32_t val_size_;
 74};

utilities/simulator_cache/sim_cache.cc:
157        miss_times_(0),

CID 1396124 (#1 of 1): Uninitialized pointer field (UNINIT_CTOR)
2. uninit_member: Non-static class member stats_ is not initialized in this constructor nor in any functions that it calls.
158        hit_times_(0) {}
159
```
Closes https://github.com/facebook/rocksdb/pull/3155

Differential Revision: D6427237

Pulled By: sagar0

fbshipit-source-id: 97e493da5fc043c5b9a3e0d33103442cffb75aad
1 parent 7b57510
Raw File
threadpool_imp.h
//  Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
//  This source code is licensed under both the GPLv2 (found in the
//  COPYING file in the root directory) and Apache 2.0 License
//  (found in the LICENSE.Apache file in the root directory).
//
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#pragma once

#include "rocksdb/threadpool.h"
#include "rocksdb/env.h"

#include <memory>
#include <functional>

namespace rocksdb {


class ThreadPoolImpl : public ThreadPool {
 public:
  ThreadPoolImpl();
  ~ThreadPoolImpl();

  ThreadPoolImpl(ThreadPoolImpl&&) = delete;
  ThreadPoolImpl& operator=(ThreadPoolImpl&&) = delete;

  // Implement ThreadPool interfaces

  // Wait for all threads to finish.
  // Discards all the jobs that did not
  // start executing and waits for those running
  // to complete
  void JoinAllThreads() override;

  // Set the number of background threads that will be executing the
  // scheduled jobs.
  void SetBackgroundThreads(int num) override;
  int GetBackgroundThreads() override;

  // Get the number of jobs scheduled in the ThreadPool queue.
  unsigned int GetQueueLen() const override;

  // Waits for all jobs to complete those
  // that already started running and those that did not
  // start yet
  void WaitForJobsAndJoinAllThreads() override;

  // Make threads to run at a lower kernel priority
  // Currently only has effect on Linux
  void LowerIOPriority();

  // Ensure there is at aleast num threads in the pool
  // but do not kill threads if there are more
  void IncBackgroundThreadsIfNeeded(int num);

  // Submit a fire and forget job
  // These jobs can not be unscheduled

  // This allows to submit the same job multiple times
  void SubmitJob(const std::function<void()>&) override;
  // This moves the function in for efficiency
  void SubmitJob(std::function<void()>&&) override;

  // Schedule a job with an unschedule tag and unschedule function
  // Can be used to filter and unschedule jobs by a tag
  // that are still in the queue and did not start running
  void Schedule(void (*function)(void* arg1), void* arg, void* tag,
                void (*unschedFunction)(void* arg));

  // Filter jobs that are still in a queue and match
  // the given tag. Remove them from a queue if any
  // and for each such job execute an unschedule function
  // if such was given at scheduling time.
  int UnSchedule(void* tag);

  void SetHostEnv(Env* env);

  Env* GetHostEnv() const;

  // Return the thread priority.
  // This would allow its member-thread to know its priority.
  Env::Priority GetThreadPriority() const;

  // Set the thread priority.
  void SetThreadPriority(Env::Priority priority);

  static void PthreadCall(const char* label, int result);

  struct Impl;

 private:

   // Current public virtual interface does not provide usable
   // functionality and thus can not be used internally to
   // facade different implementations.
   //
   // We propose a pimpl idiom in order to easily replace the thread pool impl
   // w/o touching the header file but providing a different .cc potentially
   // CMake option driven.
   //
   // Another option is to introduce a Env::MakeThreadPool() virtual interface
   // and override the environment. This would require refactoring ThreadPool usage.
   //
   // We can also combine these two approaches
   std::unique_ptr<Impl>   impl_;
};

}  // namespace rocksdb
back to top