<commit_before>;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; indent-tabs-mode: nil -*-

(in-package #:bordeaux-threads)

;;; Helper macros

(defmacro defdfun (name args doc &body body)
  (let ((docstring (gensym "DOCSTRING")))
    `(progn
       ,(unless (fboundp name)
          `(defun ,name ,args ,@body))
       (let ((,docstring (documentation ',name 'function)))
         (setf (documentation ',name 'function)
               (if ,docstring
                   (format nil "~a~@[~%~%~a~]" ,doc ,docstring)
                   ,doc))))))

(defmacro defdmacro (name args doc &body body)
  (let ((docstring (gensym "DOCSTRING")))
    `(progn
       ,(unless (fboundp name)
          `(defmacro ,name ,args ,@body))
       (let ((,docstring (documentation ',name 'function)))
         (setf (documentation ',name 'function)
               (if ,docstring
                   (format nil "~a~@[~%~%~a~]" ,doc ,docstring)
                   ,doc))))))

;;; Thread Creation

(defdfun make-thread (function &key name
                      (initial-bindings *default-special-bindings*))
  "Creates and returns a thread named NAME, which will call the
  function FUNCTION with no arguments: when FUNCTION returns, the
  thread terminates. NAME defaults to NIL if unsupplied.

  On systems that do not support multi-threading, MAKE-THREAD will
  signal an error.

  The interaction between threads and dynamic variables is in some
  cases complex, and depends on whether the variable has only a global
  binding (as established by e.g. DEFVAR/DEFPARAMETER/top-level SETQ)
  or has been bound locally (e.g. with LET or LET*) in the calling
  thread.

  - Global bindings are shared between threads: the initial value of a<commit_msg>Fix docstring setting in DEFDFUN and DEFDMACRO.<commit_after>;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; indent-tabs-mode: nil -*-

(in-package #:bordeaux-threads)

;;; Helper macros

(defmacro defdfun (name args doc &body body)
  `(progn
     ,(unless (fboundp name)
       `(defun ,name ,args ,@body))
     (setf (documentation ',name 'function)
           (or (documentation ',name 'function) ,doc))))

(defmacro defdmacro (name args doc &body body)
  `(progn
     ,(unless (fboundp name)
       `(defmacro ,name ,args ,@body))
     (setf (documentation ',name 'function)
           (or (documentation ',name 'function) ,doc))))

;;; Thread Creation

(defdfun make-thread (function &key name
                      (initial-bindings *default-special-bindings*))
  "Creates and returns a thread named NAME, which will call the
  function FUNCTION with no arguments: when FUNCTION returns, the
  thread terminates. NAME defaults to NIL if unsupplied.

  On systems that do not support multi-threading, MAKE-THREAD will
  signal an error.

  The interaction between threads and dynamic variables is in some
  cases complex, and depends on whether the variable has only a global
  binding (as established by e.g. DEFVAR/DEFPARAMETER/top-level SETQ)
  or has been bound locally (e.g. with LET or LET*) in the calling
  thread.

  - Global bindings are shared between threads: the initial value of a
{'fraction_non_alphanumeric': 0.11314102564102564, 'fraction_numerical': 0.0, 'mean_word_length': 3.053246753246753, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7536011', 'n_tokens_mistral': 965, 'n_tokens_neox': 916, 'n_words': 353}