-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproc-pid-file-threadsafe.html
More file actions
124 lines (105 loc) · 3.02 KB
/
proc-pid-file-threadsafe.html
File metadata and controls
124 lines (105 loc) · 3.02 KB
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>BarCamp Buffalo | December 2009</title>
<!-- metadata -->
<meta name="generator" content="S5" />
<meta name="version" content="S5 1.1" />
<meta name="presdate" content="20050728" />
<meta name="author" content="Mike Canzoneri" />
<meta name="company" content="Complex Spiral Consulting" />
<!-- configuration parameters -->
<meta name="defaultView" content="slideshow" />
<meta name="controlVis" content="hidden" />
<!-- style sheet links -->
<link rel="stylesheet" href="ui/black/slides.css" type="text/css" media="projection" id="slideProj" />
<link rel="stylesheet" href="ui/black/outline.css" type="text/css" media="screen" id="outlineStyle" />
<link rel="stylesheet" href="ui/black/print.css" type="text/css" media="print" id="slidePrint" />
<link rel="stylesheet" href="ui/black/opera.css" type="text/css" media="projection" id="operaFix" />
<!-- S5 JS -->
<script src="ui/black/slides.js" type="text/javascript"></script>
</head>
<body>
<div class="layout">
<div id="controls"><!-- DO NOT EDIT --></div>
<div id="currentSlide"><!-- DO NOT EDIT --></div>
<div id="header"></div>
<div id="footer">
<h2>BarCamp Buffalo | December 2009</h2>
</div>
</div>
<div class="presentation">
<div class="slide">
<h1>Proc::PID::File Update</h1>
<h3>Mike Canzoneri</h3>
<h4>Release Engineer at Synacor</h4>
</div>
<div class="slide">
<br><br><br>
<h3>
...programming with threads is treacherous. The ability of one execution stream to poke holes willy-nilly into the data space of another exposes more opportunity for disaster than you can possibly imagine. - Larry Wall, Programming Perl
</h3>
</div>
<div class="slide">
<br><br><br>
<center>
<span style="font-size: 70px;">
Sweet!
</span>
</center>
</div>
<div class="slide">
<h5>
#!/usr/bin/perl<br>
<bunch of use's><br>
use Proc::PID::File;<br>
<br>
# check for PID file<br>
die("Already Running") if Proc::PID::File->running({dir => '/tmp/'});<br>
<br>
threads->create(\&knock_knock)->join();<br>
<br>
unless (-f "test.pid") { print "OMG no PID file!\n"; }<br>
<br>
sub knock_knock<br>
{<br>
print "Who's there?\n";<br>
}<br>
</h5>
</div>
<div class="slide">
<h5>
# test for thread safety<br>
Proc::PID::File->running(%args);<br>
threads->create(sub { })->join();<br>
sleep(2);<br>
ok(-f "test.pid", "thread safe");<br>
</h5>
</div>
<div class="slide">
<h5>
sub DESTROY {<br>
my $self = shift;<br>
<br>
if (exists($INC{'threads.pm'})){<br>
return if (threads->tid() != 0);<br>
}<br>
...<br>
}
</h5>
</div>
<div class="slide">
In Closing...<br>
<ul>
<span class="incremental"><li>Don't use threads.<br></span>
<span class="incremental"><li>Use Proc::PID::File<br></span>
</span>
</div>
<div class="handout">
[any material that should appear in print but not on the slide]
</div>
</div>
</div>
</body>
</html>