summaryrefslogtreecommitdiffstats
path: root/storageframework/src/vespa/storageframework/generic/thread/thread.cpp
blob: 5ed3f7dc5e6d30a97f4b260658590ce73ec789fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "thread.h"
#include <vespa/vespalib/util/sync.h>

namespace storage {
namespace framework {

void
Thread::interruptAndJoin(vespalib::Monitor* m)
{
    interrupt();
    if (m != 0) {
        vespalib::MonitorGuard monitorGuard(*m);
        monitorGuard.broadcast();
    }
    join();
}

void
Thread::interruptAndJoin(std::mutex &m, std::condition_variable &cv)
{
    interrupt();
    {
        std::lock_guard<std::mutex> guard(m);
        cv.notify_all();
    }
    join();
}

} // framework
} // storage