~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/concurrency_test.c

  • Committer: Mark Atwood
  • Date: 2009-03-04 01:02:00 UTC
  • mto: (968.2.20 mordred)
  • mto: This revision was merged to the branch mainline in revision 971.
  • Revision ID: me@mark.atwood.name-20090304010200-t1n4xxdoil2yae9a
add gearman logging plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems, Inc.
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
1
/*
21
2
  Just a test application for threads.
22
3
  */
23
 
 
24
 
#include <config.h>
25
 
 
26
4
#include "azio.h"
 
5
#include <libdrizzleclient/libdrizzle.h>
 
6
#include <mysys/my_getopt.h>
27
7
#include <stdio.h>
28
8
#include <stdlib.h>
29
9
#include <sys/types.h>
37
17
#ifndef __WIN__
38
18
#include <sys/wait.h>
39
19
#endif
40
 
#include <memory>
41
20
 
42
21
#ifdef __WIN__
43
22
#define srandom  srand
45
24
#define snprintf _snprintf
46
25
#endif
47
26
 
48
 
#include <boost/scoped_ptr.hpp>
49
 
 
50
27
#include "azio.h"
51
28
 
52
 
#define DEFAULT_CONCURRENCY     10
53
29
#define DEFAULT_INITIAL_LOAD 10000
54
30
#define DEFAULT_EXECUTE_SECONDS 120
55
31
#define TEST_FILENAME "concurrency_test.az"
70
46
pthread_mutex_t row_lock;
71
47
 
72
48
/* Prototypes */
73
 
extern "C" {
74
 
  void *run_concurrent_task(void *p);
75
 
  void *timer_thread(void *p);
76
 
}
 
49
void *run_concurrent_task(void *p);
 
50
void *timer_thread(void *p);
77
51
void scheduler(az_method use_aio);
78
52
void create_data_file(azio_stream *write_handler, uint64_t rows);
79
53
unsigned int write_row(azio_stream *s);
104
78
int main(int argc, char *argv[])
105
79
{
106
80
 
107
 
  unsigned int method;
108
 
  drizzled::internal::my_init();
 
81
  az_method method;
 
82
  my_init();
109
83
 
110
84
  MY_INIT(argv[0]);
111
85
 
123
97
  pthread_mutex_init(&row_lock, NULL);
124
98
 
125
99
  for (method= AZ_METHOD_BLOCK; method < AZ_METHOD_MAX; method++)
126
 
    scheduler((az_method)method);
 
100
    scheduler(method);
127
101
 
128
102
  (void)pthread_mutex_destroy(&counter_mutex);
129
103
  (void)pthread_cond_destroy(&count_threshhold);
140
114
{
141
115
  unsigned int x;
142
116
  uint64_t total;
143
 
  boost::scoped_ptr<azio_stream> writer_handle_ap(new azio_stream);
144
 
  azio_stream &writer_handle= *writer_handle_ap.get();
 
117
  azio_stream writer_handle;
145
118
  thread_context_st *context;
146
119
  pthread_t mainthread;            /* Thread descriptor */
147
120
  pthread_attr_t attr;          /* Thread attributes */
196
169
    if (pthread_create(&mainthread, &attr, timer_thread,
197
170
                       (void *)&opt_timer_length) != 0)
198
171
    {
199
 
      fprintf(stderr,"%s: Could not create timer thread\n", drizzled::internal::my_progname);
 
172
      fprintf(stderr,"%s: Could not create timer thread\n", my_progname);
200
173
      exit(1);
201
174
    }
202
175
  }
268
241
  uint64_t count;
269
242
  int ret;
270
243
  int error;
271
 
  boost::scoped_ptr<azio_stream> reader_handle_ap(new azio_stream);
272
 
  azio_stream &reader_handle= *reader_handle_ap.get();
 
244
  azio_stream reader_handle;
273
245
 
274
246
  if (!(ret= azopen(&reader_handle, TEST_FILENAME, O_RDONLY,
275
247
                    context->use_aio)))