int Trick::DataRecordGroup::write_data(bool must_write) { unsigned int local_buffer_num ; unsigned int num_to_write ; unsigned int writer_offset ; if ( record and inited and (buffer_type == DR_No_Buffer or must_write) and (total_bytes_written <= max_file_size)) { // buffer_mutex is used in this one place to prevent forced calls of write_data // to not overwrite data being written by the asynchronous thread. pthread_mutex_lock(&buffer_mutex) ; local_buffer_num = buffer_num ; if ( (local_buffer_num - writer_num) > max_num ) { num_to_write = max_num ; } else { num_to_write = (local_buffer_num - writer_num) ; } writer_num = local_buffer_num - num_to_write ; //! This loop pulls a "row" of time homogeneous data and writes it to the file while ( writer_num != local_buffer_num ) { writer_offset = writer_num % max_num ; //! keep record of bytes written to file. Default max is 1GB total_bytes_written += format_specific_write_data(writer_offset) ; writer_num++ ; } pthread_mutex_unlock(&buffer_mutex) ; } return 0 ; }
int Trick::DataRecordGroup::write_data(bool must_write) { unsigned int local_buffer_num ; unsigned int num_to_write ; unsigned int writer_offset ; if ( record and inited and (buffer_type == DR_No_Buffer or must_write)) { pthread_mutex_lock(&buffer_mutex) ; local_buffer_num = buffer_num ; if ( (local_buffer_num - writer_num) > max_num ) { num_to_write = max_num ; } else { num_to_write = (local_buffer_num - writer_num) ; } writer_num = local_buffer_num - num_to_write ; //! This loop pulls a "row" of time homogeneous data and writes it to the file while ( writer_num != local_buffer_num ) { writer_offset = writer_num % max_num ; format_specific_write_data(writer_offset) ; writer_num++ ; } pthread_mutex_unlock(&buffer_mutex) ; } return 0 ; }