TinyMUSH 3.3
TinyMUSH Server
Loading...
Searching...
No Matches
Functions | Variables
cque.c File Reference

Commands and functions for manipulating the command queue. More...

#include "config.h"
#include "constants.h"
#include "typedefs.h"
#include "macros.h"
#include "externs.h"
#include "prototypes.h"
#include <stdbool.h>
#include <string.h>
#include <limits.h>
Include dependency graph for cque.c:

Functions

int a_Queue (dbref, int)
 
void s_Queue (dbref, int)
 
int QueueMax (dbref)
 
void delete_qentry (BQUE *qptr)
 Delete and free a queue entry. More...
 
int add_to (dbref doer, dbref player, int am, int attrnum)
 Adjust an object's queue or semaphore count. More...
 
void give_que (BQUE *tmp)
 Thread a queue block onto the high or low priority queue. More...
 
bool que_want (BQUE *entry, dbref ptarg, dbref otarg)
 Do we want this queue entry? More...
 
int halt_que (dbref player, dbref object)
 Remove all queued commands from a certain player. More...
 
void remove_waitq (BQUE *qptr)
 Remove an entry from the wait queue. More...
 
void do_halt_pid (dbref player, dbref cause __attribute__((unused)), int key __attribute__((unused)), char *pidstr)
 Halt a single queue entry. More...
 
void do_halt (dbref player, dbref cause, int key, char *target)
 Command interface to halt_que. More...
 
int nfy_que (dbref player, dbref sem, int attr, int key, int count)
 Notify commands from the queue and perform or discard them. More...
 
void do_notify (dbref player, dbref cause __attribute__((unused)), int key, char *what, char *count)
 Command interface to nfy_que. More...
 
int qpid_next (void)
 Get the next available queue PID. More...
 
BQUEsetup_que (dbref player, dbref cause, char *command, char *args[], int nargs, GDATA *gargs)
 Set up a queue entry. More...
 
void wait_que (dbref player, dbref cause, int wait, dbref sem, int attr, char *command, char *args[], int nargs, GDATA *gargs)
 Add commands to the wait or semaphore queues. More...
 
void do_wait_pid (dbref player, int key, char *pidstr, char *timestr)
 Adjust the wait time on an existing entry. More...
 
void do_wait (dbref player, dbref cause, int key, char *event, char *cmd, char *cargs[], int ncargs)
 Command interface to wait_que. More...
 
int que_next (void)
 Return the time in seconds until the next command should be run from the queue. More...
 
void do_second (void)
 Check the wait and semaphore queues for commands to remove. More...
 
int do_top (int ncmds)
 Execute the command at the top of the queue. More...
 
void show_que (dbref player, int key, BQUE *queue, int *qtot, int *qent, int *qdel, dbref player_targ, dbref obj_targ, const char *header)
 tell player what commands they have pending in the queue More...
 
void do_ps (dbref player, dbref cause __attribute__((unused)), int key, char *target)
 List queue. More...
 
void do_queue (dbref player, dbref cause __attribute__((unused)), int key, char *arg)
 Queue management. More...
 

Variables

int qpid_top = 1
 

Detailed Description

Commands and functions for manipulating the command queue.

Author
TinyMUSH development team (https://github.com/TinyMUSH)
Version
3.1
Date
2020-12-26

Function Documentation

◆ add_to()

int add_to ( dbref  doer,
dbref  player,
int  am,
int  attrnum 
)

Adjust an object's queue or semaphore count.

Parameters
doerDbref of doer
playerDBref of player
amAttribute map
attrnumAttribute number
Returns
int

◆ delete_qentry()

void delete_qentry ( BQUE qptr)

Delete and free a queue entry.

Parameters
qptrQueue entry

◆ do_halt()

void do_halt ( dbref  player,
dbref  cause,
int  key,
char *  target 
)

Command interface to halt_que.

Parameters
playerDBref of player
causeDBref of cause
keyKey
targetTarget to halt

Figure out what to halt

◆ do_halt_pid()

void do_halt_pid ( dbref  player,
dbref cause   __attribute__(unused),
int key   __attribute__(unused),
char *  pidstr 
)

Halt a single queue entry.

Parameters
playerDBref of player
causeDBref of cause
keyKey
pidstrPîd of the queue

Changing the player to NOTHING will flag this as halted, but we may have to delete it from the wait queue as well as the semaphore queue.

◆ do_notify()

void do_notify ( dbref  player,
dbref cause   __attribute__(unused),
int  key,
char *  what,
char *  count 
)

Command interface to nfy_que.

Parameters
playerDBref of player
causeDBref of cause
keyKey
whatCommand
countCounter

Do they have permission to set this attribute?

◆ do_ps()

void do_ps ( dbref  player,
dbref cause   __attribute__(unused),
int  key,
char *  target 
)

List queue.

Parameters
playerDBref of player
causeDBref of cause
keyKey
targetTarget

Figure out what to list the queue for

Go do it

Display stats

◆ do_queue()

void do_queue ( dbref  player,
dbref cause   __attribute__(unused),
int  key,
char *  arg 
)

Queue management.

Parameters
playerDBref of player
causeDBref of cause
keyKey
argArguments

Handle the wait queue

Handle the semaphore queue

◆ do_second()

void do_second ( void  )

Check the wait and semaphore queues for commands to remove.

move contents of low priority queue onto end of normal one this helps to keep objects from getting out of control since its affects on other objects happen only after one second this should allow @halt to be type before getting blown away by scrolling text

the point->waittime test would be 0 except the command is being put in the low priority queue to be done in one second anyway

Do the wait queue

Check the semaphore queue for expired timed-waits

< Skip if not timed-wait

◆ do_top()

int do_top ( int  ncmds)

Execute the command at the top of the queue.

Parameters
ncmdsNumber of commands to execute
Returns
int

Load scratch args

< gotta check this, as the value's * changed

◆ do_wait()

void do_wait ( dbref  player,
dbref  cause,
int  key,
char *  event,
char *  cmd,
char *  cargs[],
int  ncargs 
)

Command interface to wait_que.

Parameters
playerDBref of player
causeDBref of cause
keyKey
eventEvent
cmdCommand
cargsCommand arguments
ncargsNumber of commands

If arg1 is all numeric, do simple (non-sem) timed wait.

Semaphore wait with optional timeout

Get timeout, default 0

thing over-notified, run the command immediately

◆ do_wait_pid()

void do_wait_pid ( dbref  player,
int  key,
char *  pidstr,
char *  timestr 
)

Adjust the wait time on an existing entry.

Parameters
playerDBref of player
keyKey
pidstrPID of the entry
timestrWait time

The semaphore queue is unsorted, but the main wait queue is sorted. So we may have to go rethread.

◆ give_que()

void give_que ( BQUE tmp)

Thread a queue block onto the high or low priority queue.

Parameters
tmpQueue Entry

◆ halt_que()

int halt_que ( dbref  player,
dbref  object 
)

Remove all queued commands from a certain player.

Parameters
playerDBref of player
objectDBref of object
Returns
int

Player queue

Object queue

Wait queue

Semaphore queue

◆ nfy_que()

int nfy_que ( dbref  player,
dbref  sem,
int  attr,
int  key,
int  count 
)

Notify commands from the queue and perform or discard them.

Parameters
playerDBref of player
semDBref of sem
attrAttributes
keyKey
countCounter
Returns
int

Either run or discard the command

If we've notified enough, exit

Update the sem waiters count

◆ qpid_next()

int qpid_next ( void  )

Get the next available queue PID.

Returns
int

◆ que_next()

int que_next ( void  )

Return the time in seconds until the next command should be run from the queue.

Returns
int

If there are commands in the player queue, we want to run them immediately.

If there are commands in the object queue, we want to run them after a one-second pause.

< Skip if no timeout

◆ que_want()

bool que_want ( BQUE entry,
dbref  ptarg,
dbref  otarg 
)

Do we want this queue entry?

Parameters
entryQueue Entry
ptargPlayer target
otargObject target
Returns
bool

◆ remove_waitq()

void remove_waitq ( BQUE qptr)

Remove an entry from the wait queue.

Parameters
qptrQueue Entry

Head of the queue. Just remove it and relink.

Go find it somewhere in the queue and take it out.

◆ setup_que()

BQUE * setup_que ( dbref  player,
dbref  cause,
char *  command,
char *  args[],
int  nargs,
GDATA gargs 
)

Set up a queue entry.

Parameters
playerDBref of player
causeDBref of cause
commandCommand
argsArguments
nargsNumber of arguments
gargsGlobal registers
Returns
BQUE*

Can we run commands at all?

make sure player can afford to do it

Wizards and their objs may queue up to db_top+1 cmds. Players are limited to QUEUE_QUOTA. -mnp

halt also means no command execution allowed

Generate a PID

We passed all the tests, calculate the length of the save string.

Create the queue entry and load the save string

Set up registers and whatnot

Load the rest of the queue block

◆ show_que()

void show_que ( dbref  player,
int  key,
BQUE queue,
int *  qtot,
int *  qent,
int *  qdel,
dbref  player_targ,
dbref  obj_targ,
const char *  header 
)

tell player what commands they have pending in the queue

Parameters
playerDBref of player
keyKey
queueQueue Entry
qtotQueue Total
qentQueue Entries
qdelQueue Deleted
player_targDBref of player target
obj_targDBref of object target
headerHeader

A minor shortcut. We can never timeout-wait on a non-Semaphore attribute.

◆ wait_que()

void wait_que ( dbref  player,
dbref  cause,
int  wait,
dbref  sem,
int  attr,
char *  command,
char *  args[],
int  nargs,
GDATA gargs 
)

Add commands to the wait or semaphore queues.

Parameters
playerDBref of player
causeDBref of cause
waitDelay
semSemaphores
attrAttributes
commandCommand
argsArguments
nargsNumber of arguments
gargsGlobal registers

Set wait time, and check for integer overflow

No semaphore, put on wait queue if wait value specified. Otherwise put on the normal queue.