5. 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 9 "./lpsrc/flx_job.ipk"
     2: #ifndef __FLX_FAIO_JOB_H__
     3: #define __FLX_FAIO_JOB_H__
     4: #include <flx_faio_config.hpp>
     5: #include "demux_demuxer.hpp"
     6: #include "pthread_work_fifo.hpp"
     7: #include "faio_asyncio.hpp"
     8: 
     9: namespace flx { namespace faio {
    10: class FAIO_EXTERN job_t:
    11:   public flx_driver_request_base,
    12:   public pthread::worker_task
    13: {
    14:    pthread::worker_fifo* job_queue;
    15: public:
    16: 
    17:   // from flx_driver_request_base
    18:   bool start_async_op_impl(flx::demux::demuxer& demux);
    19: };
    20: }}
    21: 
    22: #endif
    23: 
End cpp section to faio/faio_job.hpp[1]
Start cpp section to faio/faio_job.cpp[1 /1 ]
     1: #line 33 "./lpsrc/flx_job.ipk"
     2: #include "faio_job.hpp"
     3: 
     4: namespace flx { namespace faio {
     5: // from flx_driver_request_base
     6: bool job_t::start_async_op_impl(demux::demuxer& demux)
     7: {
     8:   //fprintf(stderr,"job_t: start async_op_impl\n");
     9:   //printf("Adding task to worker queue\\n");
    10:   // get worker fifo, add this task
    11:   job_queue->add_worker_task(this);
    12:   //printf("Task added\\n");
    13:   return false;              // suspended
    14: }
    15: 
    16: }}
    17: 
    18: 
End cpp section to faio/faio_job.cpp[1]