base: Export event related symbols from base in windows

BUG=b:213153157
TEST=presubmit

Change-Id: If4b122b70c11ec1b1591296ff2f67c389fa89671
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3625708
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Vikram Auradkar 2022-05-03 20:22:59 +00:00 committed by Chromeos LUCI
parent cdb9e125ae
commit 68fb967912
3 changed files with 18 additions and 4 deletions

View file

@ -7,6 +7,7 @@ mod clock;
pub mod descriptor;
pub mod descriptor_reflection;
mod errno;
mod event;
pub mod external_mapping;
mod mmap;
mod notifiers;
@ -21,6 +22,7 @@ pub use sys::platform;
pub use alloc::LayoutAllocation;
pub use clock::{Clock, FakeClock};
pub use errno::{errno_result, Error, Result};
pub use event::{Event, EventReadResult, ScopedEvent};
pub use external_mapping::{Error as ExternalMappingError, Result as ExternalMappingResult, *};
pub use mmap::{MemoryMapping, MemoryMappingBuilder};
pub use notifiers::*;
@ -34,7 +36,6 @@ pub use tube::{Error as TubeError, RecvTube, Result as TubeResult, SendTube, Tub
cfg_if::cfg_if! {
if #[cfg(unix)] {
mod event;
mod shm;
mod wait_context;
@ -42,12 +43,12 @@ cfg_if::cfg_if! {
pub use unix::net::*;
pub use event::{Event, EventReadResult, ScopedEvent};
pub use platform::{MemoryMappingBuilderUnix, Unix as MemoryMappingUnix};
pub use shm::SharedMemory;
pub use wait_context::{EventToken, EventType, TriggeredEvent, WaitContext};
} else if #[cfg(windows)] {
pub use platform::MemoryMappingBuilderWindows;
pub use platform::EventExt;
pub use tube::{deserialize_and_recv, serialize_and_send, set_duplicate_handle_tube, set_alias_pid, DuplicateHandleTube};
} else {
compile_error!("Unsupported platform");

View file

@ -30,7 +30,10 @@ use winapi::{
};
use super::{errno_result, Error, RawDescriptor, Result};
use crate::descriptor::{AsRawDescriptor, FromRawDescriptor, IntoRawDescriptor, SafeDescriptor};
use crate::{
descriptor::{AsRawDescriptor, FromRawDescriptor, IntoRawDescriptor, SafeDescriptor},
Event as CrateEvent,
};
/// A safe wrapper around Windows synchapi methods used to mimic Linux eventfd (man 2 eventfd).
/// Since the eventfd isn't using "EFD_SEMAPHORE", we don't need to keep count so we can just use
@ -41,6 +44,16 @@ pub struct Event {
event_handle: SafeDescriptor,
}
pub trait EventExt {
fn reset(&self) -> Result<()>;
}
impl EventExt for CrateEvent {
fn reset(&self) -> Result<()> {
self.0.reset()
}
}
/// Wrapper around the return value of doing a read on an EventFd which distinguishes between
/// getting a valid count of the number of times the eventfd has been written to and timing out
/// waiting for the count to be non-zero.

View file

@ -3,7 +3,7 @@
// found in the LICENSE file.
use crate::{AsyncError, AsyncResult, EventAsync, Executor};
use base::Event;
use base::{Event, EventExt};
impl EventAsync {
pub fn new(event: Event, ex: &Executor) -> AsyncResult<EventAsync> {