std::vector<string> name(concurrentios);
std::string newName;
- bufferlist* contents[concurrentios];
+ unique_ptr<bufferlist> contents[concurrentios];
int r = 0;
bufferlist b_write;
lock_cond lc(&lock);
//set up writes so I can start them together
for (int i = 0; i<concurrentios; ++i) {
name[i] = generate_object_name_fast(i / writes_per_object);
- contents[i] = new bufferlist();
+ contents[i] = std::make_unique<bufferlist>();
snprintf(data.object_contents, data.op_size, "I'm the %16dth op!", i);
contents[i]->append(data.object_contents, data.op_size);
}
lock.unlock();
//create new contents and name on the heap, and fill them
newName = generate_object_name_fast(data.started / writes_per_object);
- newContents = contents[slot];
+ newContents = contents[slot].get();
snprintf(newContents->c_str(), data.op_size, "I'm the %16dth op!", data.started);
// we wrote to buffer, going around internal crc cache, so invalidate it now.
newContents->invalidate_crc();
--data.in_flight;
lock.unlock();
release_completion(slot);
- delete contents[slot];
- contents[slot] = 0;
}
timePassed = mono_clock::now() - data.start_time;
sync_write(run_name_meta, b_write, sizeof(int)*3);
completions_done();
- for (int i = 0; i < concurrentios; i++)
- if (contents[i])
- delete contents[i];
return 0;
data.done = 1;
lock.unlock();
pthread_join(print_thread, NULL);
- for (int i = 0; i < concurrentios; i++)
- if (contents[i])
- delete contents[i];
return r;
}
std::vector<string> name(concurrentios);
std::string newName;
- bufferlist* contents[concurrentios];
+ unique_ptr<bufferlist> contents[concurrentios];
int index[concurrentios];
int errors = 0;
double total_latency = 0;
//set up initial reads
for (int i = 0; i < concurrentios; ++i) {
name[i] = generate_object_name_fast(i / writes_per_object, pid);
- contents[i] = new bufferlist();
+ contents[i] = std::make_unique<bufferlist>();
}
lock.lock();
index[i] = i;
start_times[i] = mono_clock::now();
create_completion(i, _aio_cb, (void *)&lc);
- r = aio_read(name[i], i, contents[i], data.op_size,
+ r = aio_read(name[i], i, contents[i].get(), data.op_size,
data.op_size * (i % writes_per_object));
if (r < 0) { //naughty, doesn't clean up heap -- oh, or handle the print thread!
cerr << "r = " << r << std::endl;
// calculate latency here, so memcmp doesn't inflate it
data.cur_latency = mono_clock::now() - start_times[slot];
- cur_contents = contents[slot];
+ cur_contents = contents[slot].get();
int current_index = index[slot];
// invalidate internal crc cache
//start new read and check data if requested
start_times[slot] = mono_clock::now();
create_completion(slot, _aio_cb, (void *)&lc);
- r = aio_read(newName, slot, contents[slot], data.op_size,
+ r = aio_read(newName, slot, contents[slot].get(), data.op_size,
data.op_size * (data.started % writes_per_object));
if (r < 0) {
goto ERR;
} else {
lock.unlock();
}
- delete contents[slot];
}
timePassed = mono_clock::now() - data.start_time;
std::vector<string> name(concurrentios);
std::string newName;
- bufferlist* contents[concurrentios];
+ unique_ptr<bufferlist> contents[concurrentios];
int index[concurrentios];
int errors = 0;
int r = 0;
//set up initial reads
for (int i = 0; i < concurrentios; ++i) {
name[i] = generate_object_name_fast(i / writes_per_object, pid);
- contents[i] = new bufferlist();
+ contents[i] = std::make_unique<bufferlist>();
}
lock.lock();
index[i] = i;
start_times[i] = mono_clock::now();
create_completion(i, _aio_cb, (void *)&lc);
- r = aio_read(name[i], i, contents[i], data.op_size,
+ r = aio_read(name[i], i, contents[i].get(), data.op_size,
data.op_size * (i % writes_per_object));
if (r < 0) { //naughty, doesn't clean up heap -- oh, or handle the print thread!
cerr << "r = " << r << std::endl;
lock.unlock();
int current_index = index[slot];
- cur_contents = contents[slot];
+ cur_contents = contents[slot].get();
completion_wait(slot);
lock.lock();
r = completion_ret(slot);
//start new read and check data if requested
start_times[slot] = mono_clock::now();
create_completion(slot, _aio_cb, (void *)&lc);
- r = aio_read(newName, slot, contents[slot], data.op_size,
+ r = aio_read(newName, slot, contents[slot].get(), data.op_size,
data.op_size * (rand_id % writes_per_object));
if (r < 0) {
goto ERR;
} else {
lock.unlock();
}
- delete contents[slot];
}
timePassed = mono_clock::now() - data.start_time;