summaryrefslogtreecommitdiffstats
path: root/fastos/src/vespa/fastos/unix_thread.h
blob: c3c757e3fd9cab222b8c468b30d7eaa4ba5b4723 (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
33
34
35
36
37
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
******************************************************************************
* @author  Oivind H. Danielsen
* @date    Creation date: 2000-02-02
* @file
* Class definition for FastOS_UNIX_Thread
*****************************************************************************/

#pragma once

#include "thread.h"

class FastOS_UNIX_Thread : public FastOS_ThreadInterface
{
protected:
    pthread_t _handle;
    bool _handleValid;

    bool Initialize () override;
public:
    FastOS_UNIX_Thread(const FastOS_UNIX_Thread &) = delete;
    FastOS_UNIX_Thread& operator=(const FastOS_UNIX_Thread &) = delete;
    FastOS_UNIX_Thread(FastOS_ThreadPool *pool)
        : FastOS_ThreadInterface(pool),
          _handle(),
          _handleValid(false)
    {}

    ~FastOS_UNIX_Thread() override;

    FastOS_ThreadId GetThreadId () const noexcept override;
    static bool CompareThreadIds (FastOS_ThreadId a, FastOS_ThreadId b);
    static FastOS_ThreadId GetCurrentThreadId ();
};