1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573
|
<html>
<head>
<title>AOLserver</title>
</head>
<body>
<h1>Scheduling C Library Functions</h1>
<p>
$Header: /cvsroot/aolserver/aolserver.com/docs/devel/c/index.html,v 1.1 2002/03/07 19:15:35 kriston Exp $
<p>
<h2><a name= href=./>Ns_RegisterAtExit</a></h2>
Register an exit procedure.
<h3>Syntax</h3>
<pre>
typedef void (Ns_Callback) (void *context);
Ns_ProcHandle Ns_RegisterAtExit(
Ns_Callback *proc,
void *context
);
</pre>
<h3>Description</h3>
The Ns_RegisterAtExit function registers proc as a function to call
before AOLserver exits after all servers are shut down. The procedures
are run in last-registered first-run order.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_RegisterAtPreStartup</a></h2>
Register a procedure for pre-server startup
<h3>Syntax</h3>
<pre>
void* Ns_RegisterAtPreStartup (
Ns_Callback* proc,
void* arg
);
</pre>
<h3>Description</h3>
Register a procedure to be called just before the binder is
terminated, prior to server startup. The return value is an opaque
handle (which is currently not useful).
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_RegisterAtSignal</a></h2>
Register a procedure at HUP signal
<h3>Syntax</h3>
<pre>
void* Ns_RegisterAtSignal (
Ns_Callback* proc,
void* context
);
</pre>
<h3>Description</h3>
Register a callback to run when the HUP signal is received by the
server.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_RegisterAtStartup</a></h2>
Register a procedure for server startup
<h3>Syntax</h3>
<pre>
void* Ns_RegisterAtStartup (
Ns_Callback* proc,
void* context
);
</pre>
<h3>Description</h3>
Register a callback to run when the server is done starting up.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_RegisterServerShutdown</a></h2>
Register a shutdown procedure for a server.
<h3>Syntax</h3>
<pre>
typedef void (Ns_Callback) (void *context);
Ns_ProcHandle Ns_RegisterServerShutdown(
char *hServer,
Ns_Callback *proc,
Ns_OpContext context
);
</pre>
<h3>Description</h3>
The Ns_RegisterServerShutdown function registers proc as a shutdown
procedure on the specified server. The server calls all shutdown
procedures before shutting down, in last-registered first-run order.
The shutdown procedure takes the context as its sole argument. A
shutdown procedure is often used to close or free a resource allocated
by a module's initialization routine.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_RegisterShutdown</a></h2>
Register a shutdown procedure.
<h3>Syntax</h3>
<pre>
typedef void (Ns_Callback) (void *context);
Ns_ProcHandle Ns_RegisterShutdown(
Ns_Callback *proc,
void *context
);
</pre>
<h3>Description</h3>
The Ns_RegisterShutdown function registers proc as a shutdown
procedure. The server calls all shutdown procedures before shutting
down, in last-registered first-run order. The shutdown procedure takes
the context as its sole argument. A shutdown procedure is often used
to close or free a resource allocated by a module's initialization
routine.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclRegisterAtCreate</a></h2>
Register function for interpreter creation
<h3>Syntax</h3>
<pre>
int Ns_TclRegisterAtCreate (
Ns_TclInterpInitProc* proc,
void* arg
);
</pre>
<h3>Description</h3>
Register a procedure to be called when an interpreter is first created
for a thread.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_TclRegisterDeferred</a></h2>
Register a function for interpreter cleanup
<h3>Syntax</h3>
<pre>
void Ns_TclRegisterDeferred (
Tcl_Interp *interpPtr ,
Ns_TclDeferProc *deferProc ,
void *contex
);
</pre>
<h3>Description</h3>
Register a procedure to be called when the interpreter is cleaned up.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ScheduleDaily</a></h2>
Schedule a procedure to run once a day
<h3>Syntax</h3>
<pre>
int Ns_ScheduleDaily(
Ns_SchedProc *proc,
void *context,
int flags,
int hour,
int minute,
Ns_SchedProc *cleanup
);
</pre>
<h3>Description</h3>
The Ns_ScheduleDaily function schedules the procedure (proc) to be run
once a day at the specified time (hour and minute).
<p>
The proc is the scheduled procedure that will be run once a day. It is
a function that takes the context and id of the schedule procedure.
The id can be used in the Ns_UnscheduleProc procedure to stop the
procedure from being called again.
typedef void (Ns_SchedProc) (void *context, int id);
The context is the context to pass to the scheduled procedure.
<p>
The possible flags are NS_SCHED_ONCE and NS_SCHED_THREAD. If you
specify NS_SCHED_ONCE, the procedure will only be executed once on the
specified day and time, and it will not be re-scheduled to execute
again the next day. By default, the procedure is re-scheduled after
every time it is executed.
<p>
If you specify NS_SCHED_THREAD, the procedure will run detached in a
separate thread instead of using the one scheduled procedure thread
used by all other scheduled procedures. You should use NS_SCHED_THREAD
if the procedure will not return immediately. Note that if you use
NS_SCHED_THREAD, and the procedure is still active the next time to
run occurs, the next run is skipped instead of just delayed.
<p>
The hour can be an integer from 0 to 23, and the minute an integer
from 0 to 59.
<p>
The cleanup procedure will be run once when the proc procedure is
unscheduled.
<h3>Examples</h3>
<pre>
Run a procedure (MyProc) once in its own thread at 2:30 a.m.:
Ns_ScheduleDaily(myProc, myCtx, NS_SCHED_ONCE | NS_SCHED_THREAD,
2, 30, NULL)
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ScheduleProc</a></h2>
Schedule a procedure to run at specified intervals
<h3>Syntax</h3>
<pre>
int Ns_ScheduleProc(
void (*proc) (),
void *context,
int fNewThread,
int interval
);
</pre>
<h3>Description</h3>
The Ns_ScheduleProc function schedules the procedure proc to be run
every interval seconds, with context as an argument. The flag
fNewThread determines whether proc runs in its own thread.
Ns_ScheduleProc returns an integer id for use in the Ns_UnscheduleProc
function.
<p>
Note that the newer Ns_ScheduleProcEx function provides a superset of
the functionality in Ns_ScheduleProc.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ScheduleProcEx</a></h2>
Schedule a procedure to run at specified intervals
<h3>Syntax</h3>
<pre>
int Ns_ScheduleProcEx(
Ns_SchedProc *proc,
void *context,
int flags,
int interval,
Ns_SchedProc *cleanup
);
</pre>
<h3>Description</h3>
The Ns_ScheduleProcEx function schedules the procedure (proc) to be
run at a specific time interval specified in seconds.
Ns_ScheduleProcEx returns an integer id for use in the
Ns_UnscheduleProc function.
<p>
The proc procedure is the scheduled procedure that will be run at each
interval. It is a function that takes the context and id of the
schedule procedure. The id can be used in the Ns_UnscheduleProc
procedure to stop the procedure from being called again.
typedef void (Ns_SchedProc) (void *context, int id);
The context is the context to pass to the scheduled procedure.
<p>
The possible flags are NS_SCHED_ONCE and NS_SCHED_THREAD. If you
specify NS_SCHED_ONCE, the procedure will only be executed once on the
specified day and time, and it will not be re-scheduled to execute
again. By default, the procedure is re-scheduled after every time it
is executed.
<p>
If you specify NS_SCHED_THREAD, the procedure will run detached in a
separate thread instead of using the one scheduled procedure thread
used by all other scheduled procedures. You should use NS_SCHED_THREAD
if the procedure will not return immediately. Note that if you use
NS_SCHED_THREAD, and the procedure is still active the next time to
run occurs, the next run is skipped instead of just delayed.
<p>
The interval is the number of seconds between runs of the procedure.
<p>
The cleanup procedure will be run once when the proc procedure is
unscheduled.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_ScheduleWeekly</a></h2>
Schedule a procedure to run once a week
<h3>Syntax</h3>
<pre>
int Ns_ScheduleWeekly(
Ns_SchedProc *proc,
void *context,
int flags,
int day,
int hour,
int minute,
Ns_SchedProc *cleanup
);
</pre>
<h3>Description</h3>
The Ns_ScheduleWeekly function schedules the procedure (proc) to be
run once a week on the specified day (day) at the specified time (hour
and minute).
<p>
The proc procedure is the scheduled procedure that will be run once a
week. It is a function that takes the context and id of the schedule
procedure. The id can be used in the Ns_UnscheduleProc procedure to
stop the procedure from being called again.
typedef void (Ns_SchedProc) (void *context, int id);
The context is the context to pass to the scheduled procedure.
<p>
The possible flags are NS_SCHED_ONCE and NS_SCHED_THREAD. If you
specify NS_SCHED_ONCE, the procedure will only be executed once on the
specified day and time, and it will not be re-scheduled to execute
again the next week. By default, the procedure is re-scheduled after
every time it is executed.
<p>
If you specify NS_SCHED_THREAD, the procedure will run detached in a
separate thread instead of using the one scheduled procedure thread
used by all other scheduled procedures. You should use NS_SCHED_THREAD
if the procedure will not return immediately. Note that if you use
NS_SCHED_THREAD, and the procedure is still active the next time to
run occurs, the next run is skipped instead of just delayed.
<p>
The day can be an integer from 0 to 6, where 0 represents Sunday. The
hour can be an integer from 0 to 23, and the minute an integer from 0
to 59.
<p>
The cleanup procedure will be run once when the proc procedure is
unscheduled.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_UnscheduleProc</a></h2>
Stop a scheduled procedure
<h3>Syntax</h3>
<pre>
void Ns_UnscheduleProc (
int id
);
</pre>
<h3>Description</h3>
The Ns_UnscheduleProc function stops a scheduled procedure from
executing again. The scheduled procedure to be stopped is identified
by its id, which was returned by the Ns_Schedule* function that was
used to schedule the procedure. It is safe to call Ns_UnscheduleProc
from inside a scheduled procedure.
</pre>
<p>
<hr>
<br>
<h2><a name= href=./>Ns_WaitForStartup</a></h2>
Block until server startup
<h3>Syntax</h3>
<pre>
int Ns_WaitForStartup (void);
</pre>
<h3>Description</h3>
Block until server startup.
</pre>
<p>
<hr>
<br>
</body>
</html>
|