4. Scheduler
Start cpp section to faio/faio_drv.hpp[1
/1
]
1: #line 723 "./lpsrc/flx_faio.pak"
2:
3:
4:
5:
6:
7:
8:
9:
10:
11: namespace flx { namespace faio {
12:
13:
14:
15: class FAIO_EXTERN flx_drv {
16: flx::pthread::sleep_queue_t& ready_queue;
17: flx::pthread::worker_fifo work_fifo;
18: public:
19: flx_drv(
20: flx::pthread::sleep_queue_t& q,
21: int qbound, int nthreads
22: );
23: virtual ~flx_drv();
24:
25: void sched(void* f);
26:
27: flx::pthread::worker_fifo* get_worker_fifo() { return &work_fifo; }
28: virtual demux::timer_queue* get_sleepers() = 0;
29: };
30:
31:
32: class FAIO_EXTERN thread_wakeup {
33: public:
34: void wake() { drv->sched(f); }
35:
36: void* f;
37: flx_drv* drv;
38: };
39:
40:
41:
42:
43: #define RECORD_THREAD_INFO(w) (w).f=f;\
44: (w).drv=drv;
45:
46: }}
47:
48:
49:
Start cpp section to faio/faio_drv.cpp[1
/1
]
1: #line 773 "./lpsrc/flx_faio.pak"
2:
3:
4:
5: using namespace flx::demux;
6: namespace flx { namespace faio {
7: flx_drv::flx_drv(flx::pthread::sleep_queue_t& q, int jobqbound, int nthreads)
8: : ready_queue(q), work_fifo(jobqbound,nthreads)
9: {
10: }
11:
12: flx_drv::~flx_drv()
13: {
14: }
15:
16: void
17: flx_drv::sched(void* f)
18: {
19: ready_queue.enqueue(f);
20: }
21:
22: }}
23:
Start cpp section to faio/faio_pdrv.hpp[1
/1
]
1: #line 797 "./lpsrc/flx_faio.pak"
2:
3:
4:
5:
6:
7:
8:
9: namespace flx { namespace faio {
10:
11:
12: class FAIO_EXTERN pflx_drv : public flx_drv {
13: demux::pasync_fileio file_aio_worker;
14: demux::posix_timer_queue sleepers;
15: public:
16: pflx_drv(flx::pthread::sleep_queue_t& q, int n1, int m2, int n2, int m2);
17:
18: demux::pasync_fileio* get_aio_worker() { return &file_aio_worker; }
19: demux::timer_queue* get_sleepers() { return &sleepers; }
20: bool debug;
21: void set_debug(bool d) { debug = d; }
22: };
23: }}
24:
25:
Start cpp section to faio/faio_pdrv.cpp[1
/1
]
1: #line 823 "./lpsrc/flx_faio.pak"
2:
3:
4:
5:
6: using namespace flx::demux;
7: namespace flx { namespace faio {
8:
9:
10:
11:
12:
13:
14:
15: pflx_drv::pflx_drv(flx::pthread::sleep_queue_t& q, int n1, int m1, int n2, int m2)
16: : flx_drv(q,n1,m1), file_aio_worker(n2,m2)
17: {
18:
19:
20:
21:
22:
23:
24:
25:
26: if(debug)fprintf(stderr,"pdrv installing SIGPIPE ignorer\n");
27:
28:
29: void (*prev_handler)(int);
30: prev_handler = signal(SIGPIPE, SIG_IGN);
31:
32: if(SIG_ERR == prev_handler)
33: {
34: fprintf(stderr, "failed to install SIGPIPE ignorer\n");
35: throw -1;
36: }
37: else if(prev_handler != SIG_IGN && prev_handler != SIG_DFL)
38: {
39: fprintf(stderr,"warning: blew away prev SIGPIPE handler: %p\n",
40: prev_handler);
41: }
42: }
43:
44: }}
45: