3. Jobs

Abstract base for jobs. A job does some work asynchronously, then wakes up the fthread that scheduled it. The fthread blocks until the job is completed.

To use this class, just override doit().

Start cpp section to faio/faio_job.hpp[1 /1 ]
     1: #line 673 "./lpsrc/flx_faio.pak"
     2: #ifndef __FAIO_JOB_REQUEST__
     3: #define __FAIO_JOB_REQUEST__
     4: #include <flx_faio_config.hpp>
     5: #include "demux_demuxer.hpp"
     6: #include "pthread_work_fifo.hpp"
     7: #include "faio_drv.hpp"
     8: #include "faio_asyncio.hpp"
     9: 
    10: namespace flx { namespace faio {
    11: class FAIO_EXTERN job_t:
    12:   public flx::faio::flx_driver_request_base,
    13:   public flx::pthread::worker_task
    14: {
    15:    flx::faio::thread_wakeup   fw;
    16: public:
    17: 
    18:   // from flx_driver_request_base
    19:   bool start_async_op(flx::demux::demuxer& demux, flx::faio::flx_drv* drv,  void* f);
    20:   void finished();
    21: };
    22: }}
    23: 
    24: #endif
    25: 
End cpp section to faio/faio_job.hpp[1]
Start cpp section to faio/faio_job.cpp[1 /1 ]
     1: #line 699 "./lpsrc/flx_faio.pak"
     2: #include "faio_job.hpp"
     3: 
     4: namespace flx { namespace faio {
     5: // from flx_driver_request_base
     6: bool job_t::start_async_op(flx::demux::demuxer& demux, flx::faio::flx_drv* drv,  void* f)
     7: {
     8:   RECORD_THREAD_INFO(fw);    // so we can wake up
     9: 
    10:   //printf("Adding task to worker queue\\n");
    11:   // get worker fifo, add this task
    12:   drv->get_worker_fifo()->add_worker_task(this);
    13:   //printf("Task added\\n");
    14:   return false;              // suspended
    15: }
    16: 
    17: void job_t::finished(){
    18:   //printf("Finished\\n");
    19:   fw.wake();
    20: }
    21: }}
    22: 
End cpp section to faio/faio_job.cpp[1]