raphtory_core/lib.rs
1//! # raphtory
2//!
3//! `raphtory` is the core module for the raphtory library.
4//!
5//! The raphtory library is a temporal graph analytics tool, which allows users to create
6//! and analyze graph data with time.
7//!
8//! This crate provides the core data structures and functions for working with temporal graphs,
9//! as well as building and evaluating algorithms.
10//!
11//! **Note** this module is not meant to be used as a standalone crate, but in conjunction with the
12//! raphtory_db crate.
13//!
14//! For example code, please see the raphtory_db crate.
15//!
16//! ## Supported Platforms
17//!
18//! `raphtory` supports support for the following platforms:
19//!
20//! **Note** they must have Rust 1.83 or later.
21//!
22//! * `Linux`
23//! * `Windows`
24//! * `macOS`
25//!
26
27use std::{thread, time::Duration};
28
29use parking_lot::RwLock;
30
31pub mod entities;
32#[cfg(feature = "python")]
33mod python;
34pub mod storage;
35pub mod utils;
36
37pub(crate) fn loop_lock_write<A>(l: &RwLock<A>) -> parking_lot::RwLockWriteGuard<'_, A> {
38 const MAX_BACKOFF_US: u64 = 1000; // 1ms max
39 let mut backoff_us = 1;
40 loop {
41 if let Some(guard) = l.try_write_for(Duration::from_micros(50)) {
42 return guard;
43 }
44 thread::park_timeout(Duration::from_micros(backoff_us));
45 backoff_us = (backoff_us * 2).min(MAX_BACKOFF_US);
46 }
47}