Buffer Trigger

A data collection trigger based on the maximum number and refresh time.


Crates.io version Download docs.rs docs ci


Other language versions

简体中文

Introduction

A data collection trigger based on the maximum number and refresh time.

scenes to be used:

Basic usage

more see tests

```rust

[macro_use]

extern crate lazystatic; use buffertrigger::{BufferTrigger, SimpleBufferTrigger, SimpleBufferTriggerBuilder}; use std::{sync, thread, time::Duration};

lazystatic! { static ref BUFFERTRIGGER: SimpleBufferTrigger> = SimpleBufferTriggerBuilder::>::builder(Vec::default) .name("test".toowned()) .accumulator(|c, e| c.push(e)) .consumer(|c| log::info!("{:?}", c)) .maxlen(3) .interval(Duration::from_millis(500)) .build(); } static START: sync::Once = sync::Once::new();

[test]

fn itworks() { START.callonce(|| { thread::spawn(|| { BUFFERTRIGGER.listenclock_trigger(); }); });

BUFFER_TRIGGER.push(1);
BUFFER_TRIGGER.push(2);
BUFFER_TRIGGER.push(3);
BUFFER_TRIGGER.push(4);
BUFFER_TRIGGER.push(5);

thread::sleep(Duration::from_secs(5));

} ```

output:

text [1, 2, 3] [4, 5]

Features

This project is still under development. The following features with the check marks are supported.

If you are concerned about an unimplemented feature, please tell me and I will finish writing it ASAP.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions