Wrap thread local in function for Cygwin
Fixes #1826. See #1352 for a previous instance of a similar change.
This commit is contained in:
parent
24b739817f
commit
be54f4a0b6
3 changed files with 17 additions and 7 deletions
|
@ -22,7 +22,7 @@ struct DownloadRequest
|
||||||
std::string mimeType;
|
std::string mimeType;
|
||||||
|
|
||||||
DownloadRequest(const std::string & uri)
|
DownloadRequest(const std::string & uri)
|
||||||
: uri(uri), parentAct(curActivity) { }
|
: uri(uri), parentAct(getCurActivity()) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DownloadResult
|
struct DownloadResult
|
||||||
|
|
|
@ -6,7 +6,16 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
thread_local ActivityId curActivity = 0;
|
static thread_local ActivityId curActivity = 0;
|
||||||
|
|
||||||
|
ActivityId getCurActivity()
|
||||||
|
{
|
||||||
|
return curActivity;
|
||||||
|
}
|
||||||
|
void setCurActivity(const ActivityId activityId)
|
||||||
|
{
|
||||||
|
curActivity = activityId;
|
||||||
|
}
|
||||||
|
|
||||||
Logger * logger = makeDefaultLogger();
|
Logger * logger = makeDefaultLogger();
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,8 @@ public:
|
||||||
virtual void result(ActivityId act, ResultType type, const Fields & fields) { };
|
virtual void result(ActivityId act, ResultType type, const Fields & fields) { };
|
||||||
};
|
};
|
||||||
|
|
||||||
extern thread_local ActivityId curActivity;
|
ActivityId getCurActivity();
|
||||||
|
void setCurActivity(const ActivityId activityId);
|
||||||
|
|
||||||
struct Activity
|
struct Activity
|
||||||
{
|
{
|
||||||
|
@ -86,10 +87,10 @@ struct Activity
|
||||||
const ActivityId id;
|
const ActivityId id;
|
||||||
|
|
||||||
Activity(Logger & logger, Verbosity lvl, ActivityType type, const std::string & s = "",
|
Activity(Logger & logger, Verbosity lvl, ActivityType type, const std::string & s = "",
|
||||||
const Logger::Fields & fields = {}, ActivityId parent = curActivity);
|
const Logger::Fields & fields = {}, ActivityId parent = getCurActivity());
|
||||||
|
|
||||||
Activity(Logger & logger, ActivityType type,
|
Activity(Logger & logger, ActivityType type,
|
||||||
const Logger::Fields & fields = {}, ActivityId parent = curActivity)
|
const Logger::Fields & fields = {}, ActivityId parent = getCurActivity())
|
||||||
: Activity(logger, lvlError, type, "", fields, parent) { };
|
: Activity(logger, lvlError, type, "", fields, parent) { };
|
||||||
|
|
||||||
Activity(const Activity & act) = delete;
|
Activity(const Activity & act) = delete;
|
||||||
|
@ -121,8 +122,8 @@ struct Activity
|
||||||
struct PushActivity
|
struct PushActivity
|
||||||
{
|
{
|
||||||
const ActivityId prevAct;
|
const ActivityId prevAct;
|
||||||
PushActivity(ActivityId act) : prevAct(curActivity) { curActivity = act; }
|
PushActivity(ActivityId act) : prevAct(getCurActivity()) { setCurActivity(act); }
|
||||||
~PushActivity() { curActivity = prevAct; }
|
~PushActivity() { setCurActivity(prevAct); }
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Logger * logger;
|
extern Logger * logger;
|
||||||
|
|
Loading…
Reference in a new issue