Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,22 @@
#!/usr/bin/lasso9
local(lockfile = file('/tmp/myprocess.lockfile'))
if(#lockfile -> exists) => {
stdoutnl('Error: App is running as of ' + #lockfile -> readstring)
abort
}
handle => {
#lockfile -> delete
}
stdoutnl('Starting execution')
#lockfile -> doWithClose => {
#lockfile -> writebytes(bytes(date))
}
sleep(10000)
stdoutnl('Execution done')

View file

@ -0,0 +1,19 @@
import os, posix
let fn = getHomeDir() & "rosetta-code-lock"
proc ooiUnlink {.noconv.} = discard unlink fn
proc onlyOneInstance =
var fl = TFlock(lType: F_WRLCK.cshort, lWhence: SEEK_SET.cshort)
var fd = getFileHandle fn.open fmReadWrite
if fcntl(fd, F_SETLK, addr fl) < 0:
stderr.writeln "Another instance of this program is running"
quit 1
addQuitProc ooiUnlink
onlyOneInstance()
for i in countdown(10, 1):
echo i
sleep 1000
echo "Fin!"

View file

@ -0,0 +1,23 @@
include pGUI.e
function copydata_cb(Ihandle /*ih*/, atom pCommandLine, integer size)
-- (the first instance is sent a copy of the second one's command line)
printf(1,"COPYDATA(%s, %d)\n",{peek_string(pCommandLine), size});
return IUP_DEFAULT;
end function
function esc_close(Ihandle /*ih*/, atom c)
return iff(c=K_ESC?IUP_CLOSE:IUP_CONTINUE)
end function
IupOpen("../pGUI/")
IupSetGlobal("SINGLEINSTANCE", "Single") -- (must [partially] match the main window title)
if IupGetGlobal("SINGLEINSTANCE")!="" then
Ihandle dlg = IupDialog(IupVbox({IupLabel("hello")},"MARGIN=200x200"))
IupSetAttribute(dlg,"TITLE","Single Instance")
IupSetCallback(dlg, "K_ANY", Icallback("esc_close"))
IupSetCallback(dlg, "COPYDATA_CB", Icallback("copydata_cb"));
IupShow(dlg)
IupMainLoop()
end if
IupClose()

View file

@ -0,0 +1,12 @@
# For this to work, you need to explicitly
# store the returned fh inside a variable.
var fh = File(__FILE__).open_r
# Now call the flock() method on it
fh.flock(File.LOCK_EX | File.LOCK_NB) ->
|| die "I'm already running!"
# Your code here...
say "Running..."
Sys.sleep(20)
say 'Done!'

View file

@ -0,0 +1,26 @@
import Foundation
let globalCenter = NSDistributedNotificationCenter.defaultCenter()
let time = NSDate().timeIntervalSince1970
globalCenter.addObserverForName("OnlyOne", object: nil, queue: NSOperationQueue.mainQueue()) {not in
if let senderTime = not.userInfo?["time"] as? NSTimeInterval where senderTime != time {
println("More than one running")
exit(0)
} else {
println("Only one")
}
}
func send() {
globalCenter.postNotificationName("OnlyOne", object: nil, userInfo: ["time": time])
let waitTime = dispatch_time(DISPATCH_TIME_NOW, Int64(3 * NSEC_PER_SEC))
dispatch_after(waitTime, dispatch_get_main_queue()) {
send()
}
}
send()
CFRunLoopRun()