File tree Expand file tree Collapse file tree 4 files changed +88
-0
lines changed Expand file tree Collapse file tree 4 files changed +88
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright 2021 Developers of Pyroscope.
2+
3+ // Licensed under the Apache License, Version 2.0 <LICENSE or
4+ // https://www.apache.org/licenses/LICENSE-2.0>. This file may not be copied, modified, or distributed
5+ // except according to those terms.
6+
7+ use crate :: Result ;
8+
9+ use std:: sync:: { mpsc:: Sender , Arc , Mutex } ;
10+ use std:: { thread, thread:: JoinHandle } ;
11+
12+ #[ derive( Debug , Default ) ]
13+ pub struct Timer {
14+ /// A vector to store listeners (mpsc::Sender)
15+ txs : Arc < Mutex < Vec < Sender < u64 > > > > ,
16+
17+ /// Thread handle
18+ pub handle : Option < JoinHandle < Result < ( ) > > > ,
19+ }
20+
21+ impl Timer {
22+ pub fn initialize ( self ) -> Self {
23+ self
24+ }
25+
26+ pub fn attach_listener ( & mut self , tx : Sender < u64 > ) -> Result < ( ) > {
27+ Ok ( ( ) )
28+ }
29+
30+ pub fn drop_listeners ( & mut self ) -> Result < ( ) > {
31+ Ok ( ( ) )
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2021 Developers of Pyroscope.
2+
3+ // Licensed under the Apache License, Version 2.0 <LICENSE or
4+ // https://www.apache.org/licenses/LICENSE-2.0>. This file may not be copied, modified, or distributed
5+ // except according to those terms.
6+
7+ use crate :: Result ;
8+
9+ use std:: sync:: { mpsc:: Sender , Arc , Mutex } ;
10+ use std:: { thread, thread:: JoinHandle } ;
11+
12+ #[ derive( Debug , Default ) ]
13+ pub struct Timer {
14+ /// A vector to store listeners (mpsc::Sender)
15+ txs : Arc < Mutex < Vec < Sender < u64 > > > > ,
16+
17+ /// Thread handle
18+ pub handle : Option < JoinHandle < Result < ( ) > > > ,
19+ }
20+
21+ impl Timer {
22+ pub fn initialize ( self ) -> Self {
23+ self
24+ }
25+
26+ pub fn attach_listener ( & mut self , tx : Sender < u64 > ) -> Result < ( ) > {
27+ Ok ( ( ) )
28+ }
29+
30+ pub fn drop_listeners ( & mut self ) -> Result < ( ) > {
31+ Ok ( ( ) )
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2021 Developers of Pyroscope.
2+
3+ // Licensed under the Apache License, Version 2.0 <LICENSE or
4+ // https://www.apache.org/licenses/LICENSE-2.0>. This file may not be copied, modified, or distributed
5+ // except according to those terms.
6+
7+ // Possibly: ios, netbsd, openbsd, freebsd
8+ #[ cfg( target_os = "macos" ) ]
9+ pub mod kqueue;
10+ #[ cfg( target_os = "macos" ) ]
11+ pub use kqueue:: Timer ;
12+
13+ // Possibly: android
14+ #[ cfg( target_os = "linux" ) ]
15+ pub mod epoll;
16+ #[ cfg( target_os = "linux" ) ]
17+ pub use epoll:: Timer ;
18+
19+ #[ cfg( not( any( target_os = "linux" , target_os = "macos" ) ) ) ]
20+ pub mod sleep;
21+ #[ cfg( not( any( target_os = "linux" , target_os = "macos" ) ) ) ]
22+ pub use sleep:: Timer ;
File renamed without changes.
You can’t perform that action at this time.
0 commit comments