File: thread.sh

package info (click to toggle)
shoop 0.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 328 kB
  • ctags: 41
  • sloc: sh: 1,138; makefile: 209; perl: 44
file content (24 lines) | stat: -rw-r--r-- 553 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
#                                                                               
# Pseudothread module for shoop. These arn't real threads (no shared data),
# but they start up like threads.
#
# LGPL copyright 2000 by Adam Heath <doogie@debian.org>

OBJECT . new THREAD

THREAD . start :p '
	if [ -z "$($THIS . running)" ]; then
		$THIS . run &
		$THIS . pid = $! > /dev/null
		$THIS . running = 1 > /dev/null
	fi
'
THREAD . stop :p '
	if [ -z "$($THIS . running)" ]; then
		kill $($THIS . pid)
	fi
'
THREAD . wait :p '
	wait $($THIS . pid)
'