Skip to content

TimDeve/pthread

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pthread

A naive bindings for pthread in Carp

Example

(load "[email protected]:TimDeve/[email protected]")

(use-all Result Array)

(defn push-rand-int [arr]
  (push-back! arr (Int.random-between 0 10000)))

(defn main []
  (let-do [mutex &(Mutex.new [])
           callback &(fn [] (Mutex.access mutex &push-rand-int))]
    (Random.seed)
    (ignore
      (Thread.join-all
        (repeat 1000 &(fn [] (unsafe-from-success (Thread.create callback))))))
    (Mutex.access mutex &(fn [arr] (println* (str arr))))))