Skip to main content

fs::Aio

Types

AiocbList#

using fs::Aio::AiocbList =  var::Vector<struct aiocb *> 

Type: var::Vector< struct aiocb * >

Friends

hal::DeviceObject#

friend class hal::DeviceObject 

Type: class

Parameters:

  • hal::DeviceObject

Functions

Aio()=default#

fs::Aio::Aio ()=default

Aio(var::View view, off_t location=0)#

inline explicit

fs::Aio::Aio (var::View view, off_t location=0)

buffer() const#

inline

volatile void * fs::Aio::buffer () const

Type: volatile void *

Details#

Returns the buffer pointer.

error()#

inline

int fs::Aio::error ()

Type: int

Details#

Returns the error number of the operation.

is_busy() const#

inline

bool fs::Aio::is_busy () const

Type: bool

Details#

Returns true if operation is still in progress.

is_done() const#

inline

bool fs::Aio::is_done () const

Type: bool

Details#

Returns true if operation is complete.

nbytes() const#

inline

int fs::Aio::nbytes () const

Type: int

Details#

Returns the number of bytes to transfer.

offset() const#

inline

int fs::Aio::offset () const

Type: int

Details#

Returns the offset (or channel for Dac, Adc, Pwm, etc).

refer_to(var::View item)#

inline

Aio & fs::Aio::refer_to (var::View item)

Type: Aio &

Parameters:

Details#

Sets the buffer pointer.

ret()#

inline

int fs::Aio::ret ()

Type: int

Details#

Returns the return value of the operation.

set_location(int location)#

inline

Aio & fs::Aio::set_location (int location)

Type: Aio &

Parameters:

  • int location

set_offset(int offset)#

inline

Aio & fs::Aio::set_offset (int offset)

Type: Aio &

Parameters:

  • int offset

Details#

Sets the offset (or channcel for Dac, Adc, Pwm, etc).

set_signal(int number, int value)#

inline

Aio & fs::Aio::set_signal (int number, int value)

Type: Aio &

Parameters:

  • int number
  • int value

Details#

Causes the calling thread to receive a signal when the operation completes.

Returns:

Zero on success

set_signal_number(int number)#

inline

Aio & fs::Aio::set_signal_number (int number)

Type: Aio &

Parameters:

  • int number

set_signal_value(int value)#

inline

Aio & fs::Aio::set_signal_value (int value)

Type: Aio &

Parameters:

  • int value

suspend(const chrono::MicroTime &timeout=chrono::MicroTime(0))#

inline

Aio & fs::Aio::suspend (const chrono::MicroTime &timeout=chrono::MicroTime(0))

Type: Aio &

Parameters:

Details#

Blocks until the operation completes or timeout is reached.

Static Functions

suspend(const AiocbList &list, const chrono::MicroTime &timeout=chrono::MicroTime(0))#

inline

static int fs::Aio::suspend (const AiocbList &list, const chrono::MicroTime &timeout=chrono::MicroTime(0))

Type: int

Parameters:

Details#

Blocks until all transfers in list have completed or timeout is reached.Asynchronous IO Class.

Details

The Asynchronous IO class is used for performing asynchronous operations on hardware devices. When calling synchronous IO, the read/write function is called and then returns when the operation is complete. With Asynchronous IO, the read/write function returns immediately and the Aio class can be used to see when the operation completes.On Stratify OS, synchronous operations will always cause the running thread to yield the processor. This can be avoided by using the Aio class. Consider the following example:

#include <hal.hpp>#include <sys.hpp>#include <var.hpp>
int main(int argc, char * argv[]){  String buf = "Hello World!\n";  Uart uart(0); //we will read/write data to UART port 0  [Aio](classfs_1_1_aio#classfs_1_1_aio_1a74204e8c98038bcaf5d6b9b181dcff9e) aio(buf.data(), buf.size()); //aio uses buf as it's data
  uart.init(); //init the UART with default settings
 //First a synchronous write  uart.write(buf.c_str(), buf.size());  //this will return when the bytesare written //While bytes are writing, the processor will be used on another thread
 //Now the AIO version  uart.write(aio); //This thread keeps the processor -- so we can do something else in parallel
  while( aio.done() == false ){  Timer::wait_milliseconds(5); //wait for the operation to complete  }
  return 0;}