我在以下function withQueryParams(WrappedComponent) {
return withRouter((props) => {
const queryParams = myUtils.parseParams(props.location.search); // props.location provided by React Router
const newProps = {
...props,
queryParams: queryParams
}
return <WrappedComponent {...newProps} />
})
}
export default withQueryParams
代码段上使用队列结构创建buffer size(30)
时遇到问题。我尝试将其作为现有的代码段,但不知道要在哪里创建。有人可以帮助我,如何使用FIFO方法创建C
。代码如下。
buffer_size[30]
我想知道如何使用#include <iostream>
#include<conio.h>
int mutex=1,full=0,empty=3,x=0;
int main()
{
int n;
void producer();
void consumer();
int wait(int);
int signal(int);
printf("\n1.Producer\n2.Consumer\n3.Exit");
while(1)
{
printf("\nEnter your choice:");
scanf("%d",&n);
switch(n)
{
case 1: if((mutex<1000)&&(empty!=0))
producer();
else
printf("Buffer is full!!");
break;
case 2: if((mutex<1000)&&(full!=0))
consumer();
else
printf("Buffer is empty!!");
break;
case 3:
exit(0);
break;
}
}
return 0;
}
int wait(int s)
{
return (--s);
}
int signal(int s)
{
return(++s);
}
void producer()
{
mutex=wait(mutex);
full=signal(full);
empty=wait(empty);
x++;
printf("\nProducer produces the item %d",x);
mutex=signal(mutex);
}
void consumer()
{
mutex=wait(mutex);
full=wait(full);
empty=signal(empty);
printf("\nConsumer consumes item %d",x);
x--;
mutex=signal(mutex);
}
结构。请帮助我提高我的知识。