📄 thread.h
字号:
#ifndef __THREAD_H
#define __THREAD_H
#include "vector.h"
extern volatile struct thread
{
void(vector::* addr)( void* );
void* state;
thread* next;
}* top_thread;
#define BUSY_THREAD ( thread* )1
#include <stdio.h> // printf
void term( int );
inline void spawn( void(vector::* v)( void* ), void* state )
{
thread* next = ( thread* )top_thread;
// printf( "+" );
// fflush( stdout );
while( next == BUSY_THREAD )
next = ( thread* )top_thread;
( thread* )top_thread = BUSY_THREAD;
// printf( "-" );
// fflush( stdout );
// printf( "%%" );
// fflush( stdout );
thread* top = new thread;
// printf( "%%" );
// fflush( stdout );
top -> next = next;
top -> addr = v; // failure centers on this
top -> state = state;
( thread* )top_thread = top;
}
#endif // __THREAD_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -