2016-08-17 23:49:13 +00:00
|
|
|
// Copyright 2016 The University of North Carolina at Chapel Hill
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
// Please send all BUG REPORTS to <pavel@cs.unc.edu>.
|
|
|
|
// <http://gamma.cs.unc.edu/FasTC/>
|
2013-09-28 21:30:15 +00:00
|
|
|
|
|
|
|
#ifndef CORE_INCLUDE_THREADSAFESTREAMBUF_H_
|
|
|
|
#define CORE_INCLUDE_THREADSAFESTREAMBUF_H_
|
|
|
|
|
|
|
|
// Forward Declarations
|
|
|
|
class TCMutex;
|
|
|
|
|
|
|
|
#include <streambuf>
|
2013-09-29 01:44:50 +00:00
|
|
|
#include <iosfwd>
|
2013-09-28 21:30:15 +00:00
|
|
|
|
|
|
|
class ThreadSafeStreambuf : public ::std::streambuf {
|
|
|
|
public:
|
2013-09-29 01:44:50 +00:00
|
|
|
ThreadSafeStreambuf(std::ostream &sink);
|
2013-09-28 21:30:15 +00:00
|
|
|
virtual ~ThreadSafeStreambuf();
|
|
|
|
|
2013-09-29 01:44:50 +00:00
|
|
|
protected:
|
2013-09-28 22:11:41 +00:00
|
|
|
virtual std::streamsize xsputn(const char_type *s, std::streamsize count);
|
2013-09-28 21:30:15 +00:00
|
|
|
private:
|
|
|
|
// Not implemented -- not allowed...
|
|
|
|
ThreadSafeStreambuf(const ThreadSafeStreambuf &);
|
|
|
|
ThreadSafeStreambuf &operator=(const ThreadSafeStreambuf &);
|
2013-09-29 01:44:50 +00:00
|
|
|
std::ostream &m_Sink;
|
2013-09-28 21:30:15 +00:00
|
|
|
TCMutex *m_Mutex;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CORE_INCLUDE_THREADSAFESTREAMBUF_H_
|