module Datadog::Profiling::Ext::NativePthread

Enables interfacing with pthread via FFI

Public Class Methods

get_clock_id(thread, pthread_id) click to toggle source
# File lib/ddtrace/profiling/ext/cthread.rb, line 28
def self.get_clock_id(thread, pthread_id)
  return unless ::Thread.current == thread && pthread_id

  clock = CClockId.new
  clock[:value] = 0
  pthread_getcpuclockid(pthread_id, clock).zero? ? clock[:value] : nil
end
get_pthread_thread_id(thread) click to toggle source

NOTE: Only returns thread ID for thread that evaluates this call.

a.k.a. evaluating `get_pthread_thread_id(thread_a)` from within
`thread_b` will return `thread_b`'s thread ID, not `thread_a`'s.
# File lib/ddtrace/profiling/ext/cthread.rb, line 22
def self.get_pthread_thread_id(thread)
  return unless ::Thread.current == thread

  pthread_self
end