strikes

Zelensky addresses Western allies after Russia strikes Kyiv

Ukrainian President Volodymyr Zelensky appealed to Western allies asking them for help after Russia's most recent attack on Kyiv. "It is crucial that our forces have the necessary means to defend the country from Russian terror. I am grateful to each of our partners who help us. Timely delivery of interceptor missiles for our air defense, fulfilling agreements on defense systems, and electronic warfare production and supply are, without exaggeration, lifesaving efforts," Zelensky wrote on X. In the morning, Kyiv Mayor Vitali Klitschko reported explosions in the Ukrainian capital. A threat of a missile attack was declared in the city. It was later reported that explosions took place in Kyiv's suburbs.




strikes

'Nowhere is safe': Concerns grow as Israel strikes new areas of Lebanon

Residents of the mixed area of Aramoun express alarm after a strike on Wednesday kills eight people.




strikes

News24 | Nuclear watchdog chief heads to Iran after Israel warns of 'strikes on its nuclear facilities'

International Atomic Energy Agency chief Rafael Grossi is set to visit Tehran for crucial talks on Iran's nuclear programme, warning just ahead of his trip that room for manoeuvre is narrowing.




strikes

Andhra Pradesh High Court strikes down PIL seeking to restrain police from taking action on ‘abusive content on social media’




strikes

Israel Navy strikes Hezbollah in Beirut, while spying on distant enemies


The navy has, numerous times in the past, acknowledged that it carries out surveillance of Israel’s enemies, sometimes at a great distance.




strikes

Nothing Strikes Fear

During this difficult time, Fr. John Whiteford gives a message of hope in God, using the challenges of the life of St. John of Shanghai.




strikes

Moses Strikes the Rock

In this meditation from a vespers service in January of 2010, Fr. Pat looks at Numbers 20, in which the people of Israel complain to Moses about their situation.




strikes

Unison says no more school strikes planned

Unison said there are no more strikes planned following two weeks of industrial action in Perth and Kinross.




strikes

Federal Judge Strikes Down Illinois ‘Assault Weapon’ Ban: Major Win for Gun Owners’ Rights!

As if gun rights activists have not had enough winning for one week, with the landslide Trump election win.  Now, a major victory for gun rights advocates has unfolded in Illinois...




strikes

Israeli airstrikes hit Beirut suburbs

BEIRUT: The Israeli military carried out at least five airstrikes on the Hezbollah-controlled southern suburbs of Beirut on Tuesday, after Israel’s defence minister ruled out any ceasefire in Lebanon until Israel’s goals had been met.

Smoke rose over Beirut as blasts shook the capital around mid-morning. The explosions followed an Israeli military warning posted on social media identifying 12 sites in the southern suburbs and saying it would take action against them soon. It warned residents they were located near Hezbollah facilities.

There were no immediate reports of casualties from the latest strikes. Residents have largely fled the southern suburbs since Israel began bombing the area in September.

In Israel, air raid sirens sounded in parts of the north, sending residents running for shelter, and the military said a number of “suspicious aerial targets” were launched from Lebanon. There were no reports of injuries.

Ignited by the Gaza war, the conflict at the Lebanese-Israeli border had been rumbling on for a year before Israel went on the offensive in September, pounding wide areas of Lebanon with airstrikes and sending troops into the south.

Israel has dealt heavy blows to Hezbollah over the last seven weeks, killing many of its top leaders including Hassan Nasrallah, flattening parts of Beirut’s southern suburbs, and causing vast destruction in border villages in south Lebanon.

Meeting with Israel’s general staff for the first time, Israel’s newly appointed Defence Minister Israel Katz said on Monday there would be no ceasefire in Lebanon until Israel achieves its goals.

“Israel will not agree to any arrangement that does not guarantee Israel’s right to enforce and prevent terrorism on its own, and meet the goals of the war in Lebanon - disarming Hezbollah and its withdrawal beyond the Litani River and returning the residents of the north safely to their homes.”

Israel’s foreign minister Gideon Saar had said earlier on Monday there had been “a certain progress” in ceasefire talks, whilst adding the war against Hezbollah was not yet over.

The main challenge facing any ceasefire deal would be enforcement, he said.

Hezbollah has said it is ready for a long war against Israel and has kept up rocket fire.

SOUTH OF THE LITANI

The Lebanese government, which includes Hezbollah, has repeatedly called for a ceasefire based on the full implementation of a U.N. Resolution that ended a war between the group and Israel in 2006.

The resolution calls for the area south of the Litani to be free of all weapons other than those of the Lebanese state. Lebanon and Israel have accused each other of violating the resolution.

Israel’s offensive has driven more than 1 million people from their homes in Lebanon in the last seven weeks. Since hostilities erupted a year ago, Israeli attacks on Lebanon have killed 3,243 people and injured 14,134, the Lebanese health ministry said. Its figures do not distinguish between civilians and combatants.

Hezbollah attacks have killed roughly 100 civilians and soldiers in northern Israel, the Israeli-occupied Golan Heights, and southern Lebanon over the last year.




strikes

Death toll of Israeli strikes on UN operated school reaches 18

Women, children among casualties with six of the victims being staff members of UNRWA including the shelter's manager




strikes

West risks 'war' if it backs Ukraine long-range strikes, warns Putin

Blinken promised to review Kyiv's long-standing request for using Western-supplied weapons to strike Russian targets




strikes

Israeli strikes set off explosions in Beirut suburbs and kill 14 Palestinians in Gaza, medics say

Israeli airstrikes hit a cafeteria and a home in Gaza, killing at least 14 people, medical officials said. In Lebanon, warplanes struck the capital Beirut's southern suburbs on Tuesday after the military ordered a number of houses there to evacuate.




strikes

U.S. launches strikes against Iran-backed militant forces in Syria

U.S. forces launched strikes against nine Iran-linked targets in Syria, a response to several attacks on American troops in the region over the last 24 hours, U.S. Central Command officials said Monday.




strikes

Federal judge strikes down NLRB’s joint employer rule

Tyler, TX — A federal judge in Texas has vacated the National Labor Relations Board’s joint employer rule, but NLRB Chair Lauren McFerran says the decision is “not the last word.”




strikes

For airplanes, drone collisions a greater hazard than bird strikes: FAA study

Washington — A high-speed collision with a drone would leave an airliner with more structural damage than if a bird of similar weight struck the plane, according to a recent study from the Federal Aviation Administration’s Alliance for System Safety of UAS through Research Excellence.




strikes

Protect workers when lightning strikes

Lightning can strike with little or no warning. That’s why it can’t be ignored or taken lightly by employers or workers – particularly those who spend time outdoors.




strikes

Basic Black Live Looking at Headlines from Trayvon Martin to Three-Strikes Legislation

Originally broadcast March 23, 2012

Basic Black takes a look at national and local headlines including the outrage ignited by the fatal shooting of Trayvon Martin in Florida, the debate over Massachusetts; "three strikes" legislation, and Charles Street AME Church vs. One United Bank.

Our panel this week:
- Callie Crossley, host and executive editor, The Callie Crossley Show
- Phillip Martin, senior reporter, 89.7 WGBH radio
- Charles Yancey, Boston City Councillor
- State Rep. Russell Holmes, (D-MA)
- Alejandra St. Guillen, executive director, Oiste




strikes

Russia's Knyaz Vandal UAV strikes column of Ukrainian vehicles

Russia's fibre optic controlled Knyaz Vandal (Prince Vandal) drone struck a column of the Armed Forces of Ukraine (AFU) in the Kursk region of Russia. The attack was captured on video. The recording shows the drone flying at high speed over an asphalt road. It slows down and descends slightly when approaching an intersection. Several Ukrainian vehicles with ammunition can be seen driving in its direction. Knyaz Vandal flies up to one of the vehicles and crashes into it to explode.  Fiber optic controlled UAVs are a revolutionary weapon. According to military analyst and co-founder of Vatfor information and analytical project, Sergey Poletayev, drones controlled via fibre optic appeared as part of the scientific and technological revolution. The invention of such drones can be compared to the advent of artillery.




strikes

Several football players collapse as lightning strikes during match in Peru

A football player was killed when a flash of lightning struck him during a match between Juventud Bellavista and Familia Chocca in Peru. The incident occurred when the players were leaving the field due to bad weather. Thirty-nine-year-old defender Hugo de la Cruz Mesa died on the spot. Four other players were hospitalized, one of them remains in serious condition, Peruvian agency Andina said.




strikes

Russia now strikes Odessa ports almost every day

The Russian Aerospace Forces interrupted active ship traffic in Odessa ports. Ballistic missile strikes on the Odessa port infrastructure take place almost every day since October 6. The first strike was carried out on a vessel at sea on September 12. Afterwards, Russian Iskander missiles hit Shui Spirit container ships flying the Panamanian flag, the Paresa flying the flag of Saint Kitts and Nevis. The 22nd berth in the Yuzhny port and the 10th berth in the Odessa port were also hit.  On October 14, the Belize-flagged NS Moon and Palau-flagged Optima dry cargo ships were damaged. The latter vessel was reported to have been damaged a week ago. Local authorities also confirmed damage to a pilot boat and a grain warehouse. Three servicemen were killed.




strikes

High-Grade Gold Strikes in Brazil as New Drilling Results Reveal Untapped Potential

GoldMining Inc. (GOLD:TSX; GLDG:NYSE.American) released results from its ongoing 2024 auger drilling program at the Sao Jorge Project in the Tapajos gold district, Para State, Brazil. Read more about high-grade gold intercepts and new exploration targets at So Jorge as GoldMining extends its search in Tapajs.




strikes

Biden Administration Strikes Deal To Bring Offshore Wind To California

The Biden administration is opening the West Coast to offshore wind. Companies have largely focused on the East Coast, like this wind farm off Block Island, Rhode Island.; Credit: Don Emmert/AFP via Getty Images

Lauren Sommer | NPR

Updated May 25, 2021 at 2:56 PM ET

The Biden administration plans to open the California coast to offshore wind development, ending a long-running stalemate with the Department of Defense that has been the biggest barrier to building wind power along the Pacific Coast.

The move adds momentum to the administration's goal of reaching 100% carbon-free electricity by 2035, coming just weeks after the country's first large-scale offshore wind farm was approved off the coast of New England. Today, the country has just a handful of offshore wind turbines in the Atlantic Ocean, with around a dozen wind farms being developed in federal waters off the East Coast.

"It's an announcement that will set the stage for the long term development of clean energy and the growth of a brand new made-in-America industry," says national climate adviser Gina McCarthy. "Now we're thinking big and thinking bold."

The agreement identifies two sites off Central and Northern California with the potential to install massive floating wind turbines that could produce 4.6 gigawatts of electricity, enough to power 1.6 million homes.

Interest in offshore wind on the West Coast has grown for years, especially with California's own ambitious goal to cut greenhouse gas emissions. The deep waters off the coast have the potential to produce a significant amount of energy.

But the Defense Department has largely objected to the idea, since the Navy and Air Force use the area for training and testing operations. In response to the growing interest, the Navy released a map in 2017 putting large swaths of California waters off limits.

In 2018, the federal Bureau of Ocean Energy Management solicited interest from wind developers. But negotiations with the Department of Defense have been slow going ever since, effectively blocking wind development off California.

Tuesday's announcement outlines a compromise for a 399-square-mile area off Morro Bay, a site that's appealing to renewable energy companies because of existing transmission lines nearby that once service a retired power plant. It also identifies a location off Humboldt County in Northern California.

"It's our view that the world faces a grave and growing climate crisis," says Dr. Colin Kahl, undersecretary of defense for policy. "Climate change is both a threat to the Department of Defense's operations around the world and an existential challenge to our ability to maintain resilience here at home."

Another key site, just offshore from the Diablo Canyon nuclear power plant, was not included in Tuesday's deal. California's last-remaining nuclear plant is scheduled to completely close by 2025, freeing up more potential transmission lines for offshore wind.

The Biden administration has set a goal of jump-starting the country's offshore wind sector with 30 gigawatts of projects by 2030. Those wind farms will foster tens of thousands of jobs, according to the White House, between renewable energy installers, manufacturers and steelworkers.

"This is a major breakthrough — a major advancement that will allow California to start planning for its carbon-free electricity goals with offshore wind firmly in the picture," says Nancy Rader of the California Wind Energy Association, who also pointed to the challenges. "Offshore wind development off the coast at Morro Bay and Humboldt will require a major port facility in each area to construct the floating platforms and assemble the turbines that will require continued proactive planning by the state and federal governments."

Still, the areas identified in the agreement may not be enough for hitting the administration's clean electricity goal, as well as California's. The state is planning to get 100% of its electricity from zero-emission sources by 2045. To reach that, renewable energy needs to triple statewide with offshore wind playing a key role, reaching 10 GW, according to a recent state analysis. Tuesday's deal could provide just half of that.

A potential lease auction for the offshore wind sites could be held in mid-2022. But the projects will still have to negotiate concerns about the potential impacts on California's fishing industry and shipping channels, as well as any environmental concerns about sensitive ecosystems.

"Far too many questions remain unanswered regarding potential impacts to marine life which is dependent on a healthy ecosystem," says Mike Conroy of the Pacific Coast Federation of Fishermen's Associations. "The fishing industry has been told these areas work best for offshore wind developers; but no one has asked us what areas would work best for us."

Copyright 2021 NPR. To see more, visit https://www.npr.org.

This content is from Southern California Public Radio. View the original story at SCPR.org.




strikes

Meta Platforms strikes geothermal energy deal to power US data centers

Geothermal power is a renewable energy source that uses the Earth's internal heat to produce electricity and heat water. One-hundred and fifty megawatts is roughly enough electricity to power 38,000 homes.




strikes

WhatAcca.com Strikes Gold

For The Sixth Time in Two Months




strikes

Captivating Author Ginette Therrien Strikes the Readers with Her Latest Literary Masterpiece, "THE TRUTH IS IN THE WORDS"

By Ginette Therrien




strikes

Court Strikes Down Statutory Prohibition on Workers Posting Recordings of IMEs Online

The Washington Court of Appeals held that a law prohibiting injured workers from posting to social media recordings of their independent medical examinations is an unconstitutional prior restraint on free…




strikes

Corporate Board Diversity: Next Steps for Employers After Court Strikes Down California Board Diversity Law

On April 1, 2022, a Los Angeles County Superior Court ruled that California Assembly Bill 979—a bill designed to increase diversity and improve the persistently low number of underrepresented groups on corporate boards—violated the Equal Protection Clause of the California Constitution and was therefore unenforceable. In its ruling, the court acknowledged the pitfalls of homogeneity in business and communities, but it cautioned against quotas and specific number requirements.




strikes

U.S. Supreme Court Strikes Down Race-Conscious Admissions – What Does it Mean for Employers?

  • On June 29, 2023, the U.S. Supreme Court found that Harvard’s and UNC’s race-conscious admissions practices are unconstitutional.




strikes

Strikes in the Age of Automation and AI: How HR Can Prepare for the Future

Bradford Kelley talks about how important it is for employers to create effective AI policies.

SHRM

View (Subscription required)




strikes

SPAM strikes back

Hormel Foods makes SPAM, and for generations, the company also created jobs for families in Austin, Minnesota. Today, the story of a labor strike that threatened to tear one small town apart. (This episode was made in collaboration with The Experiment podcast.) | Subscribe to our weekly newsletter here.

Learn more about sponsor message choices: podcastchoices.com/adchoices

NPR Privacy Policy




strikes

[ K.154 (01/24) ] - Operating telecommunication facilities using lightning strikes data obtained from lightning location systems

Operating telecommunication facilities using lightning strikes data obtained from lightning location systems




strikes

Aftermath of Israeli airstrikes in Beirut, displaced people seek shelter

Aftermath of Israeli airstrikes in Beirut, displaced people seek shelter




strikes

Gatwick Airport strikes ended when workers accepted 10.3% wage increase

Gatwick Airport Strikes Ended When Workers Accepted 10.3% Wage Increase

Creative Media News...




strikes

First-pitch strikes critical for Gonzalez

Gio Gonzalez threw strikes on Thursday night – 78 to be exact, on 112 pitches — keying his one-hit work over eight dominant innings in the Nats’ 8-1 victory over the Reds. Gonzalez (2-1), the Nats’ starter most susceptible to wildness, had walked 11 in 20 innings, lasting no more than six innings in any of his previous four starts. But with the lead from the third inning on, Gonzalez was able to attack.




strikes

Federal Judge Strikes Down Georgia Abortion Restrictions

A federal judge is permanently blocking Georgia’s 2019 “heartbeat" abortion law, finding that it violates the U.S. Constitution. U.S. District Judge Steve Jones ruled against the state Monday in a lawsuit filed by abortion providers and an advocacy group.




strikes

The Hollywood strikes are over. Here’s when you could see your favorite stars and shows return

Missed your favorite actors? After nearly four months of striking, they’re coming back. Wednesday’s deal between striking actors and studios and streaming services won’t immediately restore filming to its full swing. That will take months. But the tentative agreement that both sides say include extraordinary provisions means that more than six months of labor strife in the film and television industries is drawing to a close. Soon, tens of thousands of entertainment sector workers could get back to work. And popular franchises like “Deadpool,” “Abbott Elementary” and “The Last of Us” will be a step closer to returning to screens.




strikes

Crew Evacuated After Yacht Strikes Whale

[Updated] A yacht sailing from Bermuda was abandoned yesterday [May 18], and the crew were evacuated after striking a whale and sustaining damage to the hull. Skipper Joost Gehrels, doubted that the boat — called Outer Limits — could safety return to Bermuda and issued a MayDay to request immediate assistance. Bermuda Radio contacted vessels […]




strikes

Stevenson: Boat Strikes Threatening Humpbacks

Photographs recently captured in the Challenger Banks area offer a stark reminder of the perils that whales can face in the ocean, with the whale spotted harbouring a slash across its back that whale researcher Andrew Stevenson said appears to have been caused by the prop of a small boat, lopping off its dorsal fin. Mr Stevenson […]




strikes

Lightning Strikes Roof Of Southampton Church

Last night’s lightning storm appears to have damaged the Seventh-Day Adventist Church in Southampton, with the Church’s roof sustaining damage overnight. The Bermuda Fire & Rescue Service are presently on scene assessing the situation. Dr. Sydney Gibbons, the Church’s Pastor, confirmed that is no internal damage to the church and added that they are looking […]




strikes

TurtleWare: Dynamic Vars - The Empire Strikes Back

Table of Contents

  1. Thread Local storage exhausted
  2. The layer of indirection
  3. I can fix her
  4. Let's write some tests!
  5. Summary

Thread Local storage exhausted

In the last post I've described a technique to use dynamic variables by value instead of the name by utilizing the operator PROGV. Apparently it works fine on all Common Lisp implementations I've tried except from SBCL, where the number of thread local variables is by default limited to something below 4000. To add salt to the injury, these variables are not garbage collected.

Try the following code to crash into LDB:

(defun foo ()
  (loop for i from 0 below 4096 do
    (when (zerop (mod i 100))
      (print i))
    (progv (list (gensym)) (list 42)
      (values))))
(foo)

This renders our new technique not very practical given SBCL popularity. We need to either abandon the idea or come up with a workaround.

The layer of indirection

Luckily for us we've already introduced a layer of indirection. Operators to access dynamic variables are called DLET, DSET and DREF. This means, that it is enough to provide a kludge implementation for SBCL with minimal changes to the remaining code.

The old code works the same as previously except that instead of SYMBOL-VALUE we use the accessor DYNAMIC-VARIABLE-VALUE, and the old call to PROGV is now DYNAMIC-VARIABLE-PROGV. Moreover DYNAMIC-EFFECTIVE-SLOT used functions BOUNDP and MAKUNBOUND, so we replace these with DYNAMIC-VARIABLE-BOUND-P and DYNAMIC-VARIABLE-MAKUNBOUND. To abstract away things further we also introduce the constructor MAKE-DYNAMIC-VARIABLE

(defpackage "EU.TURTLEWARE.BLOG/DLET"
  (:local-nicknames ("MOP" #+closer-mop "C2MOP"
                           #+(and (not closer-mop) ecl) "MOP"
                           #+(and (not closer-mop) ccl) "CCL"
                           #+(and (not closer-mop) sbcl) "SB-MOP"))
  (:use "CL"))
(in-package "EU.TURTLEWARE.BLOG/DLET")

(eval-when (:compile-toplevel :execute :load-toplevel)
  (unless (member :bordeaux-threads *features*)
    (error "Please load BORDEAUX-THREADS."))
  (when (member :sbcl *features*)
    (unless (member :fake-progv-kludge *features*)
      (format t "~&;; Using FAKE-PROGV-KLUDGE for SBCL.~%")
      (push :fake-progv-kludge *features*))))

(defmacro dlet (bindings &body body)
  (flet ((pred (binding)
           (and (listp binding) (= 2 (length binding)))))
    (unless (every #'pred bindings)
      (error "DLET: bindings must be lists of two values.~%~
                Invalid bindings:~%~{ ~s~%~}" (remove-if #'pred bindings))))
  (loop for (var val) in bindings
        collect var into vars
        collect val into vals
        finally (return `(dynamic-variable-progv (list ,@vars) (list ,@vals)
                           ,@body))))

(defmacro dset (&rest pairs)
  `(setf ,@(loop for (var val) on pairs by #'cddr
                 collect `(dref ,var)
                 collect val)))

(defmacro dref (variable)
  `(dynamic-variable-value ,variable))

;;; ...

(defmethod mop:slot-boundp-using-class
    ((class standard-class)
     object
     (slotd dynamic-effective-slot))
  (dynamic-variable-bound-p (slot-dvar object slotd)))

(defmethod mop:slot-makunbound-using-class
    ((class standard-class)
     object
     (slotd dynamic-effective-slot))
  (dynamic-variable-makunbound (slot-dvar object slotd)))

With these in place we can change the portable implementation to conform.

#-fake-progv-kludge
(progn
  (defun make-dynamic-variable ()
    (gensym))

  (defun dynamic-variable-value (variable)
    (symbol-value variable))

  (defun (setf dynamic-variable-value) (value variable)
    (setf (symbol-value variable) value))

  (defun dynamic-variable-bound-p (variable)
    (boundp variable))

  (defun dynamic-variable-makunbound (variable)
    (makunbound variable))

  (defmacro dynamic-variable-progv (vars vals &body body)
    `(progv ,vars ,vals ,@body)))

I can fix her

The implementation for SBCL will mediate access to the dynamic variable value with a synchronized hash table with weak keys. The current process is the key of the hash table and the list of bindings is the value of the hash table. For compatibility between implementations the top level value of the symbol will be shared.

The variable +FAKE-UNBOUND+ is the marker that signifies, that the variable has no value. When the list of bindings is EQ to +CELL-UNBOUND+, then it means that we should use the global value. We add new bindings by pushing to it.

#+fake-progv-kludge
(progn
  (defvar +fake-unbound+ 'unbound)
  (defvar +cell-unbound+ '(no-binding))

  (defclass dynamic-variable ()
    ((tls-table
      :initform (make-hash-table :synchronized t :weakness :key)
      :reader dynamic-variable-tls-table)
     (top-value
      :initform +fake-unbound+
      :accessor dynamic-variable-top-value)))

  (defun make-dynamic-variable ()
    (make-instance 'dynamic-variable))

  (defun dynamic-variable-bindings (dvar)
    (let ((process (bt:current-thread))
          (tls-table (dynamic-variable-tls-table dvar)))
      (gethash process tls-table +cell-unbound+)))

  (defun (setf dynamic-variable-bindings) (value dvar)
    (let ((process (bt:current-thread))
          (tls-table (dynamic-variable-tls-table dvar)))
      (setf (gethash process tls-table +cell-unbound+) value))))

We define two readers for the variable value - one that simply reads the value, and the other that signals an error if the variable is unbound. Writer for its value either replaces the current binding, or if the value cell is unbound, then we modify the top-level symbol value. We use the value +FAKE-UNBOUND+ to check whether the variable is bound and to make it unbound.

#+fake-progv-kludge
(progn
  (defun %dynamic-variable-value (dvar)
    (let ((tls-binds (dynamic-variable-bindings dvar)))
      (if (eq tls-binds +cell-unbound+)
          (dynamic-variable-top-value dvar)
          (car tls-binds))))

  (defun dynamic-variable-value (dvar)
    (let ((tls-value (%dynamic-variable-value dvar)))
      (when (eq tls-value +fake-unbound+)
        (error 'unbound-variable :name "(unnamed)"))
      tls-value))

  (defun (setf dynamic-variable-value) (value dvar)
    (let ((tls-binds (dynamic-variable-bindings dvar)))
      (if (eq tls-binds +cell-unbound+)
          (setf (dynamic-variable-top-value dvar) value)
          (setf (car tls-binds) value))))

  (defun dynamic-variable-bound-p (dvar)
    (not (eq +fake-unbound+ (%dynamic-variable-value dvar))))

  (defun dynamic-variable-makunbound (dvar)
    (setf (dynamic-variable-value dvar) +fake-unbound+)))

Finally we define the operator to dynamically bind variables that behaves similar to PROGV. Note that we PUSH and POP from the thread-local hash table DYNAMIC-VARIABLE-BINDINGS, so no synchronization is necessary.

#+fake-progv-kludge
(defmacro dynamic-variable-progv (vars vals &body body)
  (let ((svars (gensym))
        (svals (gensym))
        (var (gensym))
        (val (gensym)))
    `(let ((,svars ,vars))
       (loop for ,svals = ,vals then (rest ,svals)
             for ,var in ,svars
             for ,val = (if ,svals (car ,svals) +fake-unbound+)
             do (push ,val (dynamic-variable-bindings ,var)))
       (unwind-protect (progn ,@body)
         (loop for ,var in ,svars
               do (pop (dynamic-variable-bindings ,var)))))))

Let's write some tests!

But of course, we are going to also write a test framework. It's short, I promise. As a bonus point the API is compatibile with fiveam, so it is possible to drop tests as is in the appropriate test suite.

(defvar *all-tests* '())

(defun run-tests ()
  (dolist (test (reverse *all-tests*))
    (format *debug-io* "Test ~a... " test)
    (handler-case (funcall test)
      (serious-condition (c)
        (format *debug-io* "Failed: ~a~%" c))
      (:no-error (&rest args)
        (declare (ignore args))
        (format *debug-io* "Passed.~%")))))

(defmacro test (name &body body)
  `(progn
     (pushnew ',name *all-tests*)
     (defun ,name () ,@body)))

(defmacro is (form)
  `(assert ,form))

(defmacro pass ())

(defmacro signals (condition form)
  `(is (block nil
         (handler-case ,form
           (,condition () (return t)))
         nil)))

(defmacro finishes (form)
  `(is (handler-case ,form
         (serious-condition (c)
           (declare (ignore c))
           nil)
         (:no-error (&rest args)
           (declare (ignore args))
           t))))

Now let's get to tests. First we'll test our metaclass:

(defclass dynamic-let.test-class ()
  ((slot1 :initarg :slot1 :dynamic nil :accessor slot1)
   (slot2 :initarg :slot2 :dynamic t   :accessor slot2)
   (slot3 :initarg :slot3              :accessor slot3))
  (:metaclass class-with-dynamic-slots))

(defparameter *dynamic-let.test-instance-1*
  (make-instance 'dynamic-let.test-class
                 :slot1 :a :slot2 :b :slot3 :c))

(defparameter *dynamic-let.test-instance-2*
  (make-instance 'dynamic-let.test-class
                 :slot1 :x :slot2 :y :slot3 :z))

(test dynamic-let.1
  (let ((o1 *dynamic-let.test-instance-1*)
        (o2 *dynamic-let.test-instance-2*))
    (with-slots (slot1 slot2 slot3) o1
      (is (eq :a slot1))
      (is (eq :b slot2))
      (is (eq :c slot3)))
    (with-slots (slot1 slot2 slot3) o2
      (is (eq :x slot1))
      (is (eq :y slot2))
      (is (eq :z slot3)))))

(test dynamic-let.2
  (let ((o1 *dynamic-let.test-instance-1*)
        (o2 *dynamic-let.test-instance-2*))
    (signals error (slot-dlet (((o1 'slot1) 1)) nil))
    (slot-dlet (((o1 'slot2) :k))
      (is (eq :k (slot-value o1 'slot2)))
      (is (eq :y (slot-value o2 'slot2))))))

(test dynamic-let.3
  (let ((o1 *dynamic-let.test-instance-1*)
        (exit nil)
        (fail nil))
    (flet ((make-runner (values)
             (lambda ()
               (slot-dlet (((o1 'slot2) :start))
                 (let ((value (slot2 o1)))
                   (unless (eq value :start)
                     (setf fail value)))
                 (loop until (eq exit t) do
                   (setf (slot2 o1) (elt values (random (length values))))
                   (let ((value (slot2 o1)))
                     (unless (member value values)
                       (setf fail value)
                       (setf exit t))))))))
      (let ((r1 (bt:make-thread (make-runner '(:k1 :k2))))
            (r2 (bt:make-thread (make-runner '(:k3 :k4))))
            (r3 (bt:make-thread (make-runner '(:k5 :k6)))))
        (sleep .1)
        (setf exit t)
        (map nil #'bt:join-thread (list r1 r2 r3))
        (is (eq (slot2 o1) :b))
        (is (null fail))))))

Then let's test the dynamic variable itself:

(test dynamic-let.4
  "Test basic dvar operators."
  (let ((dvar (make-dynamic-variable)))
    (is (eql 42 (dset dvar 42)))
    (is (eql 42 (dref dvar)))
    (ignore-errors
     (dlet ((dvar :x))
       (is (eql :x (dref dvar)))
       (error "foo")))
    (is (eql 42 (dref dvar)))))

(test dynamic-let.5
  "Test bound-p operator."
  (let ((dvar (make-dynamic-variable)))
    (is (not (dynamic-variable-bound-p dvar)))
    (dset dvar 15)
    (is (dynamic-variable-bound-p dvar))
    (dynamic-variable-makunbound dvar)
    (is (not (dynamic-variable-bound-p dvar)))))

(test dynamic-let.6
  "Test makunbound operator."
  (let ((dvar (make-dynamic-variable)))
    (dset dvar t)
    (is (dynamic-variable-bound-p dvar))
    (finishes (dynamic-variable-makunbound dvar))
    (is (not (dynamic-variable-bound-p dvar)))))

(test dynamic-let.7
  "Test locally bound-p operator."
  (let ((dvar (make-dynamic-variable)))
    (is (not (dynamic-variable-bound-p dvar)))
    (dlet ((dvar 15))
      (is (dynamic-variable-bound-p dvar)))
    (is (not (dynamic-variable-bound-p dvar)))))

(test dynamic-let.8
  "Test locally unbound-p operator."
  (let ((dvar (make-dynamic-variable)))
    (dset dvar t)
    (is (dynamic-variable-bound-p dvar))
    (dlet ((dvar nil))
      (is (dynamic-variable-bound-p dvar))
      (finishes (dynamic-variable-makunbound dvar))
      (is (not (dynamic-variable-bound-p dvar))))
    (is (dynamic-variable-bound-p dvar))))

(test dynamic-let.9
  "Stress test the implementation (see :FAKE-PROGV-KLUDGE)."
  (finishes                              ; at the same time
    (let ((dvars (loop repeat 4096 collect (make-dynamic-variable))))
      ;; ensure tls variable
      (loop for v in dvars do
        (dlet ((v 1))))
      (loop for i from 0 below 4096
            for r = (random 4096)
            for v1 in dvars
            for v2 = (elt dvars r) do
              (when (zerop (mod i 64))
                (pass))
              (dlet ((v1 42)
                     (v2 43))
                (values))))))

(test dynamic-let.0
  "Stress test the implementation (see :FAKE-PROGV-KLUDGE)."
  (finishes                             ; can be gc-ed
    (loop for i from 0 below 4096 do
      (when (zerop (mod i 64))
        (pass))
      (dlet (((make-dynamic-variable) 42))
        (values)))))

All that is left is to test both dynamic variable implementations:

BLOG/DLET> (lisp-implementation-type)
"ECL"
BLOG/DLET> (run-tests)
Test DYNAMIC-LET.1... Passed.
Test DYNAMIC-LET.2... Passed.
Test DYNAMIC-LET.3... Passed.
Test DYNAMIC-LET.4... Passed.
Test DYNAMIC-LET.5... Passed.
Test DYNAMIC-LET.6... Passed.
Test DYNAMIC-LET.7... Passed.
Test DYNAMIC-LET.8... Passed.
Test DYNAMIC-LET.9... Passed.
Test DYNAMIC-LET.0... Passed.
NIL

And with the kludge:

BLOG/DLET> (lisp-implementation-type)
"SBCL"
BLOG/DLET> (run-tests)
Test DYNAMIC-LET.1... Passed.
Test DYNAMIC-LET.2... Passed.
Test DYNAMIC-LET.3... Passed.
Test DYNAMIC-LET.4... Passed.
Test DYNAMIC-LET.5... Passed.
Test DYNAMIC-LET.6... Passed.
Test DYNAMIC-LET.7... Passed.
Test DYNAMIC-LET.8... Passed.
Test DYNAMIC-LET.9... Passed.
Test DYNAMIC-LET.0... Passed.
NIL

Summary

In this post we've made our implementation to work on SBCL even when there are more than a few thousand dynamic variables. We've also added a simple test suite that checks the basic behavior.

As it often happens, after achieving some goal we get greedy and achieve more. That's the case here as well. In the next (and the last) post in this series I'll explore the idea of adding truly thread-local variables without a shared global value. This will be useful for lazily creating context on threads that are outside of our control. We'll also generalize the implementation so it is possible to subclass and implement ones own flavor of a dynamic variable.




strikes

Troll Dad Strikes When You Least Expect Him




strikes

The junior doctors' strikes may be over. But is trouble ahead?

The end of the pay dispute sounded too good to be true. And now some are wondering if it might be.




strikes

Israeli strikes on north Lebanon and Gaza kill dozens, officials and rescuers say

At least 20 children are among the dead in attacks north of Beirut and in northern Gaza, officials rescuers and medics say.




strikes

Houthis attack US warships after US strikes in Yemen

The navy destroyers were unharmed and repelled the attack, the Pentagon said.




strikes

Israeli strikes in Mount Lebanon villages kill 23, ministry says

The strikes reportedly destroyed residential buildings where displaced families were living.




strikes

News24 | US strikes targets to 'degrade the Iranian-backed groups' ability' in Syria

The US military has carried out strikes against targets in Syria in what the United States Central Command (CENTCOM) said was a response to recent attacks on US forces by "Iranian-aligned targets" in the country.





strikes

At least 56 people, including 20 children, killed in Israeli airstrikes in Lebanon and Gaza

Dozens of people were killed in Israeli military strikes on northern Lebanon and the Gaza strip, including as many as 20 children, authorities said.




strikes

CENTCOM strikes Iran-backed militia targets in Syria after rockets launched at U.S. forces

The U.S. military conducted retaliatory airstrikes Tuesday in Syria, targeting facilities of Iran-backed militias following rockets launched at U.S. forces in the Middle Eastern country.