public int In(byte* head, int length)
{
if (status != 0) return 0;
//while ( (is_ining) || (is_outing) ) Mai_Sleep(1);
//is_ining = 1;
#if BIT_READER_THREAD_SAFE
lock (this)
#endif
{
var @base = this.@base;
int rear = this.rear;
int front = this.front;
int max_size = this.max_size;
int yoyuu = (front - rear - 1 + max_size) % max_size;
int copy_length = (length > yoyuu) ? yoyuu : length;
int ato = max_size - rear;
int copy1 = (copy_length > ato) ? ato : copy_length;
int copy2 = (copy_length > ato) ? (copy_length - ato) : 0;
if (copy1 != 0)
{
//for (int n = 0; n < copy1; n++) @base[rear + n] = head[n];
Marshal.Copy(new IntPtr(head), @base, rear, copy1);
rear = (rear + copy1) % max_size;
head += copy1;
}
if (copy2 != 0)
{
//for (int n = 0; n < copy2; n++) @base[rear + n] = head[n];
Marshal.Copy(new IntPtr(head), @base, rear, copy2);
rear = (rear + copy2) % max_size;
head += copy2;
}
this.rear = rear;
//is_ining = 0;
return copy_length;
}
}