Skip to content

process id

Alairion edited this page May 8, 2021 · 3 revisions

Name

Defined in header <nes/process.hpp>

class process
{
public:
    struct id{};
}

Description

nes::process::id is a trivially copyable type that serves as a unique identifier of a process within the system.

Non-member functions

(1) constexpr bool operator==(process::id lhs, process::id rhs) noexcept;
(2) constexpr bool operator!=(process::id lhs, process::id rhs) noexcept;
(3) constexpr bool operator<(process::id lhs, process::id rhs) noexcept;
(4) constexpr bool operator<=(process::id lhs, process::id rhs) noexcept;
(5) constexpr bool operator>(process::id lhs, process::id rhs) noexcept;
(6) constexpr bool operator>=(process::id lhs, process::id rhs) noexcept;
template<typename CharT, typename Traits>
(7) std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, nes::process::id id);
  1. Checks whether lhs and rhs represent the same process.
  2. Checks whether lhs and rhs do not represent the same process.
  3. Compares lhs and rhs in such a way, that lhs and rhs are totally ordered.
  4. Compares lhs and rhs in such a way, that lhs and rhs are totally ordered.
  5. Compares lhs and rhs in such a way, that lhs and rhs are totally ordered.
  6. Compares lhs and rhs in such a way, that lhs and rhs are totally ordered.
  7. Writes a textual representation of a process identifier in os.

Helper class

namespace std
{
    template<>
    (1) struct hash<nes::process::id>;
}
  1. Template specialization of std::hash for nes::process::id.

Example

Here is an example in which we display the current process id.

main.cpp

#include <iostream>

#include <nes/process.hpp>

int main()
{
    //nes::this_process::get_id() returns the calling process's id.
    std::cout << "Current process has id " << nes::this_process::get_id() << std::endl; 
}

Possible output

Current process has id 42
Clone this wiki locally