VSM C++ SDK
Vehicle Specific Modules SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ugcs::vsm::internal::Poll_io_controller Class Reference

Linux-specific implementation for I/O controller. More...

#include <poll_io_controller.h>

Inheritance diagram for ugcs::vsm::internal::Poll_io_controller:
ugcs::vsm::File_processor::Native_controller

Classes

struct  Io_cb
 Control block for I/O operation. More...
 

Public Member Functions

virtual void Enable () override
 Enable the controller. More...
 
virtual void Disable () override
 Disable the controller. More...
 
virtual void Register_handle (File_processor::Stream::Native_handle &) override
 Register new opened file handle. More...
 
virtual void Unregister_handle (File_processor::Stream::Native_handle &) override
 Unregister previously registered file handle. More...
 
void Delete_handle (int fd)
 Delete handle. More...
 
bool Queue_operation (Io_cb &io_cb)
 Queue IO operation. More...
 
bool Cancel_operation (Io_cb &io_cb)
 Cancel pending operation. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ugcs::vsm::File_processor::Native_controller
static std::unique_ptr
< Native_controller
Create ()
 Create controller instance. More...
 

Detailed Description

Linux-specific implementation for I/O controller.

Member Function Documentation

bool ugcs::vsm::internal::Poll_io_controller::Cancel_operation ( Io_cb io_cb)

Cancel pending operation.

Parameters
io_cbOperation control block.
Returns
True if cancelled, false if not cancelled (e.g. too late).
void ugcs::vsm::internal::Poll_io_controller::Delete_handle ( int  fd)

Delete handle.

Possibly deferred. This is a workaround of kernel panic bug in OSX. The scenario: 1) create pipe with descriptors p1, p2. 2) open serial port with descriptor fd. 3) poll on two descriptors p1 and fd in separate thread. 4) issue write on p2. This triggers read event on p1 and wakes up poll(). 5) close(fd)

Results:

  • When (4) and (5) are close enough poll does not wake up and close(fd) blocks and triggers kernel panic. This does not happen 100% of time but if the above code is put into loop it takes ~20-100 iterations to trigger.
  • When (4) and (5) are >10ms apart the poll wakes up and close succeeds.
  • If close(fd) is called before write(p2) then I could not repeat the kernel panic. Solution:

Do not close the fd while it is in polling state. Close it after poll returns.

virtual void ugcs::vsm::internal::Poll_io_controller::Disable ( )
overridevirtual

Disable the controller.

Implements ugcs::vsm::File_processor::Native_controller.

virtual void ugcs::vsm::internal::Poll_io_controller::Enable ( )
overridevirtual

Enable the controller.

Implements ugcs::vsm::File_processor::Native_controller.

bool ugcs::vsm::internal::Poll_io_controller::Queue_operation ( Io_cb io_cb)

Queue IO operation.

The provided callback is called when the operation completes with Io_cb structure filled.

Returns
True if succeeded, false otherwise. Check errno for error code.
virtual void ugcs::vsm::internal::Poll_io_controller::Register_handle ( File_processor::Stream::Native_handle )
inlineoverridevirtual

Register new opened file handle.

Implements ugcs::vsm::File_processor::Native_controller.

virtual void ugcs::vsm::internal::Poll_io_controller::Unregister_handle ( File_processor::Stream::Native_handle )
inlineoverridevirtual

Unregister previously registered file handle.

Implements ugcs::vsm::File_processor::Native_controller.


The documentation for this class was generated from the following file: