Revision 1228 branches/threaded2merge/src/linad99/adthread.h

adthread.h (revision 1228)
1 1
#if !defined(__ADXTHREAD__)
2 2
#define __ADXTHREAD__ 
3

  
3 4
#include <unistd.h>     /* Symbolic Constants */
4 5
#include <sys/types.h>  /* Primitive System Data Types */ 
5 6
#include <errno.h>      /* Errors */
......
8 9
#include <pthread.h>    /* POSIX Threads */
9 10
#include <string.h>     /* String handling */
10 11

  
11
/* struct to hold data to be passed to a thread
12
 *    this shows how multiple data items can be passed to a thread */
13
  union a_union 
14
  {
15
    char * p;
16
    double d;
17
  };
18
 //     //
19
 // /* prototype for thread routine */
20
 void admb_thread(void * ptr);
21
 // 
22
 typedef char * pchar;
23
 typedef ofstream * pofstream;
24
 typedef void* (*pthreadfun)(void*);
25
 typedef pthreadfun * ppthreadfun;
26
 typedef pthread_mutex_t * ppthread_mutex_t;  
27
 typedef pthread_cond_t * ppthread_cond_t;
12
typedef ofstream * pofstream;
13
typedef void* (*pthreadfun)(void*);
14
typedef pthreadfun * ppthreadfun;
15
typedef pthread_mutex_t * ppthread_mutex_t;  
16
typedef pthread_cond_t * ppthread_cond_t;
28 17

  
29

  
30
  class thread_data
18
class new_thread_data
19
{
20
public:
21
  new_thread_data(void)
31 22
  {
32
  public:
33
    int thread_no;
34
    int bufsize;
35
    int m;
36
  };
37
  class dvar_fish_stock_history;
38
  class dvar_len_fish_stock_history;
39
  class new_thread_data
40
  {
41
  public:
42
    int thread_no;
43
    int m;
44
    dvar_len_fish_stock_history * pfsh;
45
    new_thread_data(void);
46
  };
47
 // 
48
 typedef char * pchar;
49
 // 
50
  class adpthread_manager
51
  {
52
    int num_code;
53
    static int old_buffer_flag;
54
    int logflag;
55
    static __thread int slave_number;
56
    adtimer * adt;
57
    pofstream * logfiles;
58
    ppthreadfun ppf;
59
  public:
60
    static int is_slave(void) { if (slave_number)
23
    thread_no = 0;
24
  }
25
public:
26
  int thread_no;
27
};
28
class adpthread_manager
29
{
30
  int num_code;
31
  static int old_buffer_flag;
32
  int logflag;
33
  static __thread int slave_number;
34
  adtimer * adt;
35
  pofstream * logfiles;
36
  ppthreadfun ppf;
37
public:
38
  adpthread_manager(int ns,int bs);
39
  adpthread_manager(int ngroups,ivector& group_num,int bs);
40
  virtual ~adpthread_manager() {}
41

  
42
public:
43
  static int is_slave(void) { if (slave_number)
61 44
                                  return 1;
62 45
                                else
63 46
                                  return 0; }
64
    static int is_master(void) { if (slave_number)
47
  static int is_master(void) { if (slave_number)
65 48
                                  return 0;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff