Skip to content

Commit

Permalink
localize unsafe blocks in QT_WAKER_VTABLE
Browse files Browse the repository at this point in the history
  • Loading branch information
ratijas committed Apr 22, 2021
1 parent df696b5 commit f25dac0
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions qmetaobject/src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,33 @@ use std::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
use crate::connections::SignalArgArrayToTuple;


static QT_WAKER_VTABLE: RawWakerVTable = unsafe {
RawWakerVTable::new(
|s: *const ()| {
RawWaker::new(
cpp!([s as "Waker *"] -> *const() as "Waker *" {
s->refs++;
return s;
}),
&QT_WAKER_VTABLE,
)
},
|s: *const ()| {
cpp!([s as "Waker *"] {
s->wake();
s->deref();
})
},
|s: *const ()| {
cpp!([s as "Waker *"] {
s->wake();
})
},
|s: *const ()| {
cpp!([s as "Waker *"] {
s->deref();
})
},
)
};
static QT_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(
|s: *const ()| {
RawWaker::new(
cpp!(unsafe [s as "Waker *"] -> *const() as "Waker *" {
s->refs++;
return s;
}),
&QT_WAKER_VTABLE,
)
},
|s: *const ()| {
cpp!(unsafe [s as "Waker *"] {
s->wake();
s->deref();
})
},
|s: *const ()| {
cpp!(unsafe [s as "Waker *"] {
s->wake();
})
},
|s: *const ()| {
cpp!(unsafe [s as "Waker *"] {
s->deref();
})
},
);

cpp! {{

Expand Down

0 comments on commit f25dac0

Please sign in to comment.