add comment

This commit is contained in:
ubuntu201711081 2020-12-14 10:19:49 +00:00
parent d177b33177
commit f2e8bf2376
3 changed files with 22 additions and 15 deletions

View File

@ -1,29 +1,30 @@
#include<stdio.h>
#include<time.h>
#include<stdbool.h>
#include<stddef.h>
#ifndef _DISPLAY_BAR_H_
#define _DISPLAY_BAR_H_
//declare for raw operation
typedef unsigned raw_progress_bar_t;
void lock_scrolled();
void unlock_scrolled();
void ready_progress_bar();
void quit_progress_bar();
void add_scrolled_unlocked(unsigned int i);
raw_progress_bar_t create_raw_progress_bar();
void RawDisplayProgressBar(raw_progress_bar_t bar,size_t offset,size_t total,const char * filename);
//you should call before using progrees bar.
void ready_progress_bar();
//quit progress bar system.
void quit_progress_bar();
//same as isatty
bool isatty_file(FILE * file);
//
void myd_perror(const char * msg);
int myd_vfprintf(int line,FILE * f,const char * msg,va_list arg);
typedef struct {
raw_progress_bar_t bar;

View File

@ -318,7 +318,7 @@ void init_shared_state(shared_state_t * state) {
pthread_cond_init(&state->ready,NULL);
}
#endif
//
//argument for thread worker
typedef struct WorkerArgument
{
int id;
@ -365,10 +365,11 @@ void * worker_proc(void * data){
#endif
for(;;){
pthread_mutex_lock(&globalState.sock_mutex);
//wait until request come.
while (queue_isempty(&globalState.socks)){
pthread_cond_wait(&globalState.ready,&globalState.sock_mutex);
}
csock = dequeue(&globalState.socks);
csock = dequeue(&globalState.socks); //dequeue socket descriptor for request.
#ifdef USE_TRACE
ts_top_begin = dequeue(&globalState.trace_timer);
#endif
@ -377,6 +378,7 @@ void * worker_proc(void * data){
clock_gettime(Top_Trace_Timer_ID,&ts_top_end);
clock_gettime(Bottom_Trace_Timer_ID,&ts_bottom_begin);
#endif
//process request.
if((fd = read_request(csock,args->buf,args->bufsize)) > 0){
send_response(csock,fd,args->buf,args->bufsize);
close(fd);

View File

@ -2,6 +2,10 @@
#define _TIMERHELPER_H_
#include <sys/time.h>
#ifndef __always_inline
#define __always_inline
#endif
__always_inline struct timespec timespec_sub(struct timespec a,struct timespec b){
struct timespec ret;
ret.tv_sec = a.tv_sec - b.tv_sec;