Files
clang-p2996/parallel-libs/streamexecutor/lib/Stream.cpp
Jason Henline fb62147949 [SE] Add .clang-format
Summary:
The .clang-tidy file is copied from the top-level LLVM source directory.

Also fix warnings generated by clang-format:

* Moved SimpleHostPlatformDevice.h so its header include guard could
  have the right format.
* Changed signatures of methods taking llvm::Twine by value to take it
  by const ref instead.
* Add "noexcept" to some move constructors and assignment operators.
* Removed a bunch of places where single-statement loops and
  conditionals were surrounded with braces. (This was not found by the
  current clang-tidy, but with a local patch that I hope to upstream
  soon.)

Reviewers: jlebar, jprice

Subscribers: parallel_libs-commits

Differential Revision: https://reviews.llvm.org/D24468

llvm-svn: 281374
2016-09-13 19:25:43 +00:00

55 lines
1.8 KiB
C++

//===-- Stream.cpp - General stream implementation ------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file contains the implementation details for a general stream object.
///
//===----------------------------------------------------------------------===//
#include <cassert>
#include "streamexecutor/Stream.h"
namespace streamexecutor {
Stream::Stream(PlatformDevice *D, const void *PlatformStreamHandle)
: PDevice(D), PlatformStreamHandle(PlatformStreamHandle),
ErrorMessageMutex(llvm::make_unique<llvm::sys::RWMutex>()) {
assert(D != nullptr &&
"cannot construct a stream object with a null platform device");
assert(PlatformStreamHandle != nullptr &&
"cannot construct a stream object with a null platform stream handle");
}
Stream::Stream(Stream &&Other) noexcept
: PDevice(Other.PDevice), PlatformStreamHandle(Other.PlatformStreamHandle),
ErrorMessageMutex(std::move(Other.ErrorMessageMutex)),
ErrorMessage(std::move(Other.ErrorMessage)) {
Other.PDevice = nullptr;
Other.PlatformStreamHandle = nullptr;
}
Stream &Stream::operator=(Stream &&Other) noexcept {
PDevice = Other.PDevice;
PlatformStreamHandle = Other.PlatformStreamHandle;
ErrorMessageMutex = std::move(Other.ErrorMessageMutex);
ErrorMessage = std::move(Other.ErrorMessage);
Other.PDevice = nullptr;
Other.PlatformStreamHandle = nullptr;
return *this;
}
Stream::~Stream() {
if (PlatformStreamHandle)
// TODO(jhen): Handle error condition here.
consumeError(PDevice->destroyStream(PlatformStreamHandle));
}
} // namespace streamexecutor