forked from rtbkit/rtbkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'datacratic-upstream_16_07_2015'
- Loading branch information
Showing
26 changed files
with
705 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* exception_ptr.cc | ||
Wolfgang Sourdeau, July 2015 | ||
Copyright (c) 2015 Datacratic. All rights reserved. | ||
*/ | ||
|
||
#include "exception_ptr.h" | ||
|
||
|
||
using namespace std; | ||
using namespace ML; | ||
|
||
|
||
/****************************************************************************/ | ||
/* EXCEPTIONPTR HANDLER */ | ||
/****************************************************************************/ | ||
|
||
bool | ||
ExceptionPtrHandler:: | ||
hasException() | ||
{ | ||
std::unique_lock<mutex> guard(excLock_); | ||
return bool(excPtr_); | ||
} | ||
|
||
void | ||
ExceptionPtrHandler:: | ||
takeException(std::exception_ptr newPtr) | ||
{ | ||
std::unique_lock<mutex> guard(excLock_); | ||
excPtr_ = newPtr; | ||
} | ||
|
||
void | ||
ExceptionPtrHandler:: | ||
takeCurrentException() | ||
{ | ||
takeException(std::current_exception()); | ||
} | ||
|
||
void | ||
ExceptionPtrHandler:: | ||
rethrowIfSet() | ||
{ | ||
std::unique_lock<mutex> guard(excLock_); | ||
if (excPtr_) { | ||
std::exception_ptr ptr = excPtr_; | ||
excPtr_ = nullptr; | ||
std::rethrow_exception(ptr); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* exception_ptr.h -*- C++ -*- | ||
Wolfgang Sourdeau, July 2015 | ||
Copyright (c) 2015 Datacratic. All rights reserved. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <exception> | ||
#include <mutex> | ||
|
||
|
||
namespace ML { | ||
|
||
/****************************************************************************/ | ||
/* EXCEPTIONPTR HANDLER */ | ||
/****************************************************************************/ | ||
|
||
/* This class provides thread-safe handling of exception-ptr. */ | ||
struct ExceptionPtrHandler { | ||
bool hasException(); | ||
void takeException(std::exception_ptr newPtr); | ||
void takeCurrentException(); | ||
void rethrowIfSet(); | ||
void clear() | ||
{ takeException(nullptr); } | ||
|
||
private: | ||
std::mutex excLock_; | ||
std::exception_ptr excPtr_; | ||
}; | ||
|
||
} // namespace Datacratic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.