Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() {
// just annotate the type here; the actual data is provided later in the
// run() call.
let mut event_loop: EventLoop<LoopSignal> =
EventLoop::try_new().expect("Failed to initialize the event loop!");
EventLoop::new().expect("Failed to initialize the event loop!");

// Retrieve a handle. It is used to insert new sources into the event loop
// It can be cloned, allowing you to insert sources from within source
Expand Down
6 changes: 3 additions & 3 deletions benches/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use calloop::timer::TimeoutAction;
use criterion::{criterion_group, criterion_main, Criterion};

fn single(c: &mut Criterion) {
let mut event_loop = calloop::EventLoop::<()>::try_new().unwrap();
let mut event_loop = calloop::EventLoop::<()>::new().unwrap();
let loop_handle = event_loop.handle();

let timer = calloop::timer::Timer::from_duration(Duration::from_secs(60 * 10));
Expand All @@ -27,7 +27,7 @@ fn single(c: &mut Criterion) {
}

fn mixed(c: &mut Criterion) {
let mut event_loop = calloop::EventLoop::<()>::try_new().unwrap();
let mut event_loop = calloop::EventLoop::<()>::new().unwrap();
let loop_handle = event_loop.handle();

let timer = calloop::timer::Timer::from_duration(Duration::from_secs(60 * 10 - 1));
Expand Down Expand Up @@ -60,7 +60,7 @@ fn mixed(c: &mut Criterion) {
}

fn mixed_multiple(c: &mut Criterion) {
let mut event_loop = calloop::EventLoop::<()>::try_new().unwrap();
let mut event_loop = calloop::EventLoop::<()>::new().unwrap();
let loop_handle = event_loop.handle();

for _ in 0..1000 {
Expand Down
2 changes: 1 addition & 1 deletion doc/src/adapt_io_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() -> std::io::Result<()> {
// ANCHOR_END: decl_executor

// ANCHOR: decl_loop
let mut event_loop = EventLoop::try_new()?;
let mut event_loop = EventLoop::new()?;
let handle = event_loop.handle();

handle
Expand Down
2 changes: 1 addition & 1 deletion doc/src/async_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() -> std::io::Result<()> {
// ANCHOR_END: decl_executor

// ANCHOR: decl_loop
let mut event_loop = EventLoop::try_new()?;
let mut event_loop = EventLoop::new()?;
let handle = event_loop.handle();

handle
Expand Down
2 changes: 1 addition & 1 deletion doc/src/timer_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use calloop::{
};

fn main() {
let mut event_loop = EventLoop::try_new().expect("Failed to initialize the event loop!");
let mut event_loop = EventLoop::new().expect("Failed to initialize the event loop!");

// ANCHOR: decl_source
let timer = Timer::from_duration(Duration::from_secs(5));
Expand Down
2 changes: 1 addition & 1 deletion examples/high_precision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use calloop::{

fn main() {
// As of calloop v0.11 there is no difference between low and high precision event loops.
let mut event_loop = EventLoop::try_new().expect("Failed to initialize the event loop!");
let mut event_loop = EventLoop::new().expect("Failed to initialize the event loop!");

let before = Instant::now();

Expand Down
2 changes: 1 addition & 1 deletion examples/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() {
// just annotate the type here; the actual data is provided later in the
// run() call.
let mut event_loop: EventLoop<LoopSignal> =
EventLoop::try_new().expect("Failed to initialize the event loop!");
EventLoop::new().expect("Failed to initialize the event loop!");

// Retrieve a handle. It is used to insert new sources into the event loop
// It can be cloned, allowing you to insert sources from within source
Expand Down
8 changes: 4 additions & 4 deletions src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ mod tests {

#[test]
fn read_write() {
let mut event_loop = crate::EventLoop::try_new().unwrap();
let mut event_loop = crate::EventLoop::new().unwrap();
let handle = event_loop.handle();
let (exec, sched) = executor().unwrap();
handle
Expand Down Expand Up @@ -460,7 +460,7 @@ mod tests {

#[test]
fn read_write_vectored() {
let mut event_loop = crate::EventLoop::try_new().unwrap();
let mut event_loop = crate::EventLoop::new().unwrap();
let handle = event_loop.handle();
let (exec, sched) = executor().unwrap();
handle
Expand Down Expand Up @@ -515,7 +515,7 @@ mod tests {
fn readable() {
use std::io::Write;

let mut event_loop = crate::EventLoop::try_new().unwrap();
let mut event_loop = crate::EventLoop::new().unwrap();
let handle = event_loop.handle();
let (exec, sched) = executor().unwrap();
handle
Expand Down Expand Up @@ -554,7 +554,7 @@ mod tests {
fn writable() {
use std::io::{BufReader, BufWriter, Read, Write};

let mut event_loop = crate::EventLoop::try_new().unwrap();
let mut event_loop = crate::EventLoop::new().unwrap();
let handle = event_loop.handle();
let (exec, sched) = executor().unwrap();
handle
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//! // just annotate the type here; the actual data is provided later in the
//! // run() call.
//! let mut event_loop: EventLoop<LoopSignal> =
//! EventLoop::try_new().expect("Failed to initialize the event loop!");
//! EventLoop::new().expect("Failed to initialize the event loop!");
//!
//! // Retrieve a handle. It is used to insert new sources into the event loop
//! // It can be cloned, allowing you to insert sources from within source
Expand Down
42 changes: 21 additions & 21 deletions src/loop_logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl<'l, Data> EventLoop<'l, Data> {
/// Create a new event loop
///
/// Fails if the initialization of the polling system failed.
pub fn try_new() -> crate::Result<Self> {
pub fn new() -> crate::Result<Self> {
let poll = Poll::new()?;
let poller = poll.poller.clone();
let handle = LoopHandle {
Expand Down Expand Up @@ -842,7 +842,7 @@ mod tests {

#[test]
fn dispatch_idle() {
let mut event_loop = EventLoop::try_new().unwrap();
let mut event_loop = EventLoop::new().unwrap();

let mut dispatched = false;

Expand All @@ -859,7 +859,7 @@ mod tests {

#[test]
fn cancel_idle() {
let mut event_loop = EventLoop::try_new().unwrap();
let mut event_loop = EventLoop::new().unwrap();

let mut dispatched = false;

Expand All @@ -879,7 +879,7 @@ mod tests {

#[test]
fn wakeup() {
let mut event_loop = EventLoop::try_new().unwrap();
let mut event_loop = EventLoop::new().unwrap();

let signal = event_loop.get_signal();

Expand All @@ -894,7 +894,7 @@ mod tests {

#[test]
fn wakeup_stop() {
let mut event_loop = EventLoop::try_new().unwrap();
let mut event_loop = EventLoop::new().unwrap();

let signal = event_loop.get_signal();

Expand All @@ -910,7 +910,7 @@ mod tests {

#[test]
fn additional_events() {
let mut event_loop: EventLoop<'_, Lock> = EventLoop::try_new().unwrap();
let mut event_loop: EventLoop<'_, Lock> = EventLoop::new().unwrap();
let mut lock = Lock {
lock: Rc::new((
// Whether the lock is locked
Expand Down Expand Up @@ -1045,7 +1045,7 @@ mod tests {
fn default_additional_events() {
let (sender, channel) = channel();
let mut test_source = NoopWithDefaultHandlers { channel };
let mut event_loop = EventLoop::try_new().unwrap();
let mut event_loop = EventLoop::new().unwrap();
event_loop
.handle()
.insert_source(Box::new(&mut test_source), |_, _, _| {})
Expand Down Expand Up @@ -1103,7 +1103,7 @@ mod tests {

#[test]
fn additional_events_synthetic() {
let mut event_loop: EventLoop<'_, Lock> = EventLoop::try_new().unwrap();
let mut event_loop: EventLoop<'_, Lock> = EventLoop::new().unwrap();
let mut lock = Lock {
lock: Rc::new(Cell::new(false)),
};
Expand Down Expand Up @@ -1212,7 +1212,7 @@ mod tests {
}
}

let event_loop = EventLoop::<()>::try_new().unwrap();
let event_loop = EventLoop::<()>::new().unwrap();
let fd = LeakedFd(ManuallyDrop::new(unsafe {
std::os::unix::io::OwnedFd::from_raw_fd(420)
}));
Expand All @@ -1227,7 +1227,7 @@ mod tests {
fn invalid_token() {
let (_ping, source) = crate::sources::ping::make_ping().unwrap();

let event_loop = EventLoop::<()>::try_new().unwrap();
let event_loop = EventLoop::<()>::new().unwrap();
let handle = event_loop.handle();
let reg_token = handle.insert_source(source, |_, _, _| {}).unwrap();
handle.remove(reg_token);
Expand All @@ -1247,7 +1247,7 @@ mod tests {
let source = crate::sources::generic::Generic::new(read, Interest::EMPTY, Mode::Level);
let dispatcher = Dispatcher::new(source, |_, _, _| Ok(PostAction::Continue));

let event_loop = EventLoop::<()>::try_new().unwrap();
let event_loop = EventLoop::<()>::new().unwrap();
let handle = event_loop.handle();
let ret = handle.register_dispatcher(dispatcher.clone());

Expand All @@ -1262,7 +1262,7 @@ mod tests {

#[test]
fn disarm_rearm() {
let mut event_loop = EventLoop::<bool>::try_new().unwrap();
let mut event_loop = EventLoop::<bool>::new().unwrap();
let (ping, ping_source) = make_ping().unwrap();

let ping_token = event_loop
Expand Down Expand Up @@ -1353,7 +1353,7 @@ mod tests {
}
}

let mut event_loop = EventLoop::<u32>::try_new().unwrap();
let mut event_loop = EventLoop::<u32>::new().unwrap();

let (ping1, source1) = make_ping().unwrap();
let (ping2, source2) = make_ping().unwrap();
Expand Down Expand Up @@ -1399,7 +1399,7 @@ mod tests {
fn change_interests() {
use rustix::io::write;
use rustix::net::{recv, socketpair, AddressFamily, RecvFlags, SocketFlags, SocketType};
let mut event_loop = EventLoop::<bool>::try_new().unwrap();
let mut event_loop = EventLoop::<bool>::new().unwrap();

let (sock1, sock2) = socketpair(
AddressFamily::UNIX,
Expand Down Expand Up @@ -1485,7 +1485,7 @@ mod tests {

#[test]
fn kill_source() {
let mut event_loop = EventLoop::<Option<RegistrationToken>>::try_new().unwrap();
let mut event_loop = EventLoop::<Option<RegistrationToken>>::new().unwrap();

let handle = event_loop.handle();
let (ping, ping_source) = make_ping().unwrap();
Expand Down Expand Up @@ -1517,7 +1517,7 @@ mod tests {
struct RefSender<'a>(&'a mpsc::Sender<()>);
let mut ref_sender = RefSender(&sender);

let mut event_loop = EventLoop::<RefSender<'_>>::try_new().unwrap();
let mut event_loop = EventLoop::<RefSender<'_>>::new().unwrap();
let (ping, ping_source) = make_ping().unwrap();
let _ping_token = event_loop
.handle()
Expand All @@ -1544,7 +1544,7 @@ mod tests {
use crate::sources::timer::TimeoutFuture;
use std::time::Duration;

let mut evl = EventLoop::<()>::try_new().unwrap();
let mut evl = EventLoop::<()>::new().unwrap();

let mut data = 22;
let timeout = {
Expand All @@ -1569,7 +1569,7 @@ mod tests {
use crate::sources::timer;
use std::time::Duration;

let mut evl = EventLoop::<()>::try_new().unwrap();
let mut evl = EventLoop::<()>::new().unwrap();

let mut data = 22;
let timeout = {
Expand Down Expand Up @@ -1604,7 +1604,7 @@ mod tests {
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};

let mut evl = EventLoop::<RegistrationToken>::try_new().unwrap();
let mut evl = EventLoop::<RegistrationToken>::new().unwrap();
let handle = evl.handle();

let data = Arc::new(Mutex::new(1));
Expand Down Expand Up @@ -1695,7 +1695,7 @@ mod tests {
}

// Now the actual test
let mut evl = EventLoop::<bool>::try_new().unwrap();
let mut evl = EventLoop::<bool>::new().unwrap();
evl.handle()
.insert_source(WithSubSource { token: None }, |_, _, ran| {
*ran = true;
Expand Down Expand Up @@ -1746,7 +1746,7 @@ mod tests {

#[test]
fn weak_loop_handle() {
let mut event_loop: EventLoop<()> = EventLoop::try_new().unwrap();
let mut event_loop: EventLoop<()> = EventLoop::new().unwrap();
let weak_handle1 = event_loop.handle().downgrade();
let weak_handle2 = weak_handle1.clone();
let weak_handle3 = weak_handle1.clone();
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ mod tests {
ping2,
};

let mut event_loop = crate::EventLoop::<[bool; 3]>::try_new().unwrap();
let mut event_loop = crate::EventLoop::<[bool; 3]>::new().unwrap();
let handle = event_loop.handle();

let token = handle
Expand Down
6 changes: 3 additions & 3 deletions src/sources/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ mod tests {

#[test]
fn basic_channel() {
let mut event_loop = crate::EventLoop::try_new().unwrap();
let mut event_loop = crate::EventLoop::new().unwrap();

let handle = event_loop.handle();

Expand Down Expand Up @@ -333,7 +333,7 @@ mod tests {

#[test]
fn basic_sync_channel() {
let mut event_loop = crate::EventLoop::try_new().unwrap();
let mut event_loop = crate::EventLoop::new().unwrap();

let handle = event_loop.handle();

Expand Down Expand Up @@ -391,7 +391,7 @@ mod tests {

#[test]
fn test_more_than_1024() {
let mut event_loop = crate::EventLoop::try_new().unwrap();
let mut event_loop = crate::EventLoop::new().unwrap();
let handle = event_loop.handle();

let (tx, rx) = channel::<()>();
Expand Down
4 changes: 2 additions & 2 deletions src/sources/futures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ mod tests {

#[test]
fn ready() {
let mut event_loop = crate::EventLoop::<u32>::try_new().unwrap();
let mut event_loop = crate::EventLoop::<u32>::new().unwrap();

let handle = event_loop.handle();

Expand Down Expand Up @@ -453,7 +453,7 @@ mod tests {

#[test]
fn more_than_1024() {
let mut event_loop = crate::EventLoop::<()>::try_new().unwrap();
let mut event_loop = crate::EventLoop::<()>::new().unwrap();
let handle = event_loop.handle();

let (exec, sched) = executor::<()>().unwrap();
Expand Down
Loading
Loading