view example/word_count/ppe/Read.cc @ 1978:8fbe022126e1 draft

add Blocked Read files
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Thu, 13 Mar 2014 02:15:06 +0900
parents example/bm_search/ppe/Read.cc@a8f4227d6a21
children
line wrap: on
line source

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <iostream>
#include <vector>
#include <cstdlib>

#include "SchedTask.h"
#include "Print.h"
#include "Func.h"
#include "WordCount.h"

/* これは必須 */
SchedDefineTask1(READ_TASK,read_task);

static int
read_task(SchedTask *s, void *rbuf, void *wbuf)
{
    long fd = (long)s->get_param(0);
    long start_read_position = (long)s->get_param(1);
    long end_read_position = (long)s->get_param(2);
    char *read_text = (char*)s->get_output(wbuf,0);

    long read_size = end_read_position - start_read_position;

    pread(fd, read_text, read_size , start_read_position);

    return 0;
}