• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

extphprs / ext-php-rs / 24471721058

15 Apr 2026 06:37PM UTC coverage: 65.871% (-0.02%) from 65.895%
24471721058

Pull #727

github

web-flow
fix: install cargo-codspeed via cargo install instead of taiki-e action
Pull Request #727: Add CodSpeed continuous performance benchmarks

8560 of 12995 relevant lines covered (65.87%)

32.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/embed/thread.rs
1
use super::ffi::{ext_php_rs_sapi_per_thread_init, ext_php_rs_sapi_per_thread_shutdown};
2

3
/// RAII guard for PHP ZTS thread-local state.
4
///
5
/// Initializes PHP thread-local storage on creation and cleans it up on drop.
6
/// Must be created on a dedicated OS thread after the main SAPI has been
7
/// started with `sapi_startup()` + `php_module_startup()`.
8
///
9
/// # Safety
10
///
11
/// The guard must not outlive the SAPI module. Drop all guards before calling
12
/// `php_module_shutdown()`.
13
///
14
/// # Examples
15
///
16
/// ```rust,no_run
17
/// use ext_php_rs::embed::PhpThreadGuard;
18
///
19
/// std::thread::spawn(|| {
20
///     let _guard = PhpThreadGuard::new();
21
///     // ... execute PHP requests on this thread ...
22
/// });
23
/// ```
24
#[must_use]
25
pub struct PhpThreadGuard {
26
    _private: (),
27
}
28

29
impl PhpThreadGuard {
30
    /// Initialize PHP thread-local state for the current OS thread.
31
    pub fn new() -> Self {
×
32
        unsafe {
×
33
            ext_php_rs_sapi_per_thread_init();
×
34
        }
×
35
        Self { _private: () }
×
36
    }
×
37
}
38

39
impl Default for PhpThreadGuard {
40
    fn default() -> Self {
×
41
        Self::new()
×
42
    }
×
43
}
44

45
impl Drop for PhpThreadGuard {
46
    fn drop(&mut self) {
×
47
        unsafe {
×
48
            ext_php_rs_sapi_per_thread_shutdown();
×
49
        }
×
50
    }
×
51
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc